0

I've followed this documentation and have successfully installed the Microsoft "Visual Studio Code Remote - SSH" extension and was able to connect remotely to my laptop. But the issue is, my connectivity is limited. If I want to SSH to a WAN address, I have to use a proxy. For example if I want to SSH to my VPS, I have to use this command on Cygwin on my Windows machine:

ssh -o ProxyCommand="nc -X 5 -x 127.0.0.1:1080 %h %p" root@x.x.x.x

But how do I configure VSCode to use a proxy for the SSH connection? Is there a way to modify the SSH command that VSCode runs so that I can include the nc command so that it uses my proxy?

starball
  • 20,030
  • 7
  • 43
  • 238
Shayan
  • 709
  • 1
  • 15
  • 31

1 Answers1

0

The documentation states that when you add a new ssh host, you can enter an ssh command to use instead of just a host name.

https://code.visualstudio.com/docs/remote/ssh#_remember-hosts-and-advanced-settings

Start by selecting Remote-SSH: Add New SSH Host... from the Command Palette (F1, Ctrl+Shift+P) or clicking on the Add New icon in the SSH Remote Explorer in the Activity Bar.

You'll then be asked to enter the SSH connection information. You can either enter a host name

Or the full ssh command you would use to connect to the host from the command line.

Finally, you'll be asked to pick a config file to use. You can also set the "remote.SSH.configFile" property in your User settings.json file if you want to use a different config file than those listed. The extension takes care of the rest!

For example, entering ssh -i ~/.ssh/id_rsa-remote-ssh yourname@remotehost.yourcompany.com in the input box would generate this entry:

Host remotehost.yourcompany.com
    User yourname
    HostName another-host-fqdn-or-ip-goes-here
    IdentityFile ~/.ssh/id_rsa-remote-ssh

Also possibly of interest to you: the ProxyCommand and ProxyJump fields for entries in ssh config files (see man ssh_config(5)).

starball
  • 20,030
  • 7
  • 43
  • 238
  • Yes but it fails. `Failed to parse remote port from server output` – Shayan Feb 24 '23 at 18:55
  • possibly related: https://github.com/microsoft/vscode-remote-release/issues/5111, https://github.com/microsoft/vscode-remote-release/issues/5099, https://stackoverflow.com/q/55979701/11107541 – starball Feb 24 '23 at 19:08