cho*_*tte 7 ssh remote-server visual-studio-code
我以前从未连接过远程服务器。我想连接到我公司的远程服务器,然后跳转到另一个IP地址。
我在这里按照VS Code指南连接到服务器,但我不知道如何跳转到IP地址。
有人可以帮助我吗?多谢!
cho*_*tte 11
我想到了。
我想连接到我公司的私人服务器。为此,我必须连接到公司的主机服务器。当我在主机服务器中时,我必须连接到专用服务器(很抱歉没有以更清晰的方式表达我的问题)。
我将我的解决方案留在这里以供将来参考。在 VS Code 中,执行 F1(Mac 上为 fn+F1)-> 远程 SSH:连接到主机 -> 配置 SSH 主机 -> /Users//.ssh/config。
从那里,编辑配置文件,如下所示:
Host <host-name>
HostName <IP-address>
Port <specify-port-number-here>
User <user-name>
### The Remote Host
Host <private-server-name>
HostName <IP-address>
Port <specify-port-number-here>
User <user-name>
ProxyJump <host-name>
Run Code Online (Sandbox Code Playgroud)
保存配置文件并通过 F1 -> Remote-SSH 连接到私有服务器:连接到主机 -> private-server-name
我已设法使用 ProxyCommand 选项使其正常工作,如VSCode Remote SSH Tips & Tricks page中所述,因为 chocolatte 的答案不适用于 VSCode 1.51.1:
# Jump box with public IP address
Host jump-box
HostName <Jump-Box-IP>
User <Your-Jump-Box-User-Name>
IdentityFile path/to/.ssh/id_rsa
# Target machine with private IP address
Host target-box
HostName <IP address of target>
User <Your-Private-Machine's-User-Name>
IdentityFile path/to/.ssh/id_rsa
ProxyCommand ssh -q -W %h:%p jump-box
Run Code Online (Sandbox Code Playgroud)
注意:您可以为两台主机使用相同的 IdentityFile
更新:一段时间后,它停止工作了。解决这个问题的方法是将 ssh 更改为 ssh.exe:
ProxyCommand ssh.exe -q -W %h:%p jump-box
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12465 次 |
| 最近记录: |