0%

vscode远程开发的代理配置

去年vscode就支持了远程开发,通过ssh连接到服务器,就像在本地写代码一样,实在是太爽了。

但是有一个问题是,vscode的ssh无法通过代理访问,官方文档上的方法需要一台跳板机来完成。

方法一

1
2
3
4
5
6
7
8
9
10
11
12
# Jump box with public IP address
Host jump-box
HostName 52.179.157.97
User sana
IdentityFile ~/.ssh/jumpbox

# Target machine with private IP address
Host target-box
HostName <IP address of target>
User sana
IdentityFile ~/.ssh/target
ProxyCommand ssh -q -W %h:%p jump-box

详见:remote-ssh-tips-and-tricks

但是这样太不方便了,两台服务器,配置过于复杂了。

方法二

可以通过git自带的connect.exe来完成,可以在git安装目录中找到这个exe文件。

1
2
3
4
Host xxx.xxx.xxx.xxx
HostName xxx.xxx.xxx.xxx
User root
ProxyCommand C:\\Program\ Files\\Git\\mingw64\\bin\\connect.exe -H 127.0.0.1:1081 %h %p

注意

vscode常规代理配置方法,是在运行时需要通过命令行。

1
vscode --proxy-server=http://127.0.0.1:1080