VS Code连接远程服务器时如何跳转到某个IP地址?

How to jump to an IP address when connected to a remote server on VS Code?

我以前从未连接到远程服务器。我想连接到我公司的远程服务器然后跳转到另一个IP地址。

我按照 VS Code 指南 here 连接到服务器,但我不知道如何跳转到 IP 地址。

有人能帮帮我吗?非常感谢!

我想通了。

我想连接到我公司的私人服务器。为此,我必须连接到我公司的主机服务器。当我在主机服务器中时,我必须连接到私人服务器(抱歉没有更清楚地表述我的问题)。

我将我的解决方案留在这里以供将来参考。 在 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>

保存配置文件并通过 F1 -> Remote-SSH: Connect to Host -> private-server-name 连接到私有服务器

我已经设法使用 ProxyCommand 选项让它工作,如 VSCode Remote SSH Tips & Tricks page 中所述,因为巧克力的答案对我来说对 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

注意:您可以为两个主机使用相同的 IdentityFile

更新:一段时间后它停止工作了。解决这个问题的方法是将 ssh 更改为 ssh.exe:

ProxyCommand ssh.exe -q -W %h:%p jump-box