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  改为Git安装目录下connect程序的绝对路径;
# -S                使用socks代理,也可以选其他参数,见connect.exe帮助信息;
# 127.0.0.1:10810   改为对应的IP和端口;
# %h                是一个占位符,表示要连接的目标机,也就是Hostname指定的ip或者主机名。
# %p                同样也是占位符,表示要连接到目标机的端口。

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