This post will solve the issue where you need to first login to a remote server as an intermediary proxy and then connect to the other server, all via visual studio code.
For this we need to use the remote host feature of visual studio code like we do to connect with any regular remote server.
However, for the entry of our server, we will also add a proxy in configuration, pointing to our jump host.
Open vs code, then goto Remote Explorer in the side menu icons, then click on Configure to edit
.ssh/config code will look like this:
Host any-name-for-this-entry HostName <host-ip-or-url> User <username> ProxyCommand ssh -W %h:%p <username>@<proxy-server-ip-or-url>
Save and then connect to this entry. It will connect you to the final host, while going through the proxy host to the final host.
Note that you can also change the setting for keeping server alive, so that it doesn’t break the connection when there is no activity (time is added in seconds). The .ssh/config file looks like this with it:
Host any-name-for-this-entry ServerAliveInterval 60 HostName <host-ip-or-url> User <username> ProxyCommand ssh -W %h:%p <username>@<proxy-server-ip-or-url>
You can also change the stay alive setting for all entries in the config file by adding it for Host wildcard, like:
Host * ServerAliveInterval 60 Host any-name-for-this-entry HostName <host-ip-or-url> User <username> ProxyCommand ssh -W %h:%p <username>@<proxy-server-ip-or-url>
You can also seperate out the first proxy host and the final host and then use alias of entry, like this:
Host * ServerAliveInterval 60 Host proxy-jump-host HostName <proxy-jump-host-ip-or-url> User <proxy-jump-host-username> Host final-remote-host HostName <final-remote-host-ip-or-url> User <final-remote-host-username> ProxyCommand ssh -W %h:%p proxy-jump-host
Note for windows users: you might have to replace the word
You can also use ssh keys instead of using passwords.