Setting Up an SSH Proxy in VSCode

There is little material online about setting up an SSH proxy in VSCode, and what exists either requires installing dedicated software or simply does not work. I finally found one that works. The proxy is provided by Git. Compared with other proxy software, Git is probably installed on most machines. This method applies to the Windows platform.

Steps

Open the configuration file of the SSH extension and modify it according to your actual installation path:

1
2
3
4
5
6
7
ProxyCommand C:\Program Files\Git\mingw64\bin\connect.exe -S 127.0.0.1:1080 %h %p

# C:\Program Files\Git\mingw64\bin\connect.exe  replace with the absolute path to connect.exe in your Git installation directory;
# -S                use a SOCKS proxy; other options are available, see connect.exe help;
# 127.0.0.1:1080   replace with the corresponding IP and port;
# %h                a placeholder for the target host to connect to, i.e. the IP or hostname given by Hostname.
# %p                likewise a placeholder for the port to connect to on the target host.

The final SSH configuration data looks roughly like this:

1
2
3
4
5
Host NewBee
  HostName 114.114.114.114
  User root
  Port 22
  ProxyCommand C:\Program Files\Git\mingw64\bin\connect.exe -S 127.0.0.1:1080 %h %p