我正在尝试从 docker 容器通过 SSH 连接到远程服务器。 docker 容器位于 Mac 上。连接到远程服务器的所有身份验证都是从 Mac 完成的,而不是 docker 容器。
因此这是不可能的
ssh -J host.docker.internal remote-server
然而,可以像这样以菊花链方式连接 ssh 命令
ssh -tt host.docker.internal ssh remote-server
我希望能够编辑 docker 容器上的 ssh 配置,这样我就可以简单地执行以下操作
ssh remote-server
我已经尝试了所有常用指令,但无法使其正常工作。
有趣的是,我尝试过的配置之一如下......
Host remote-server
ProxyCommand ssh -tt [email protected] ssh USER@%h
然后执行ssh -v remote-server
显示我想要运行的命令,但终端只是挂起并且没有建立连接
root@bc9912af3ad4:~/.ssh# ssh -v USER@remote-server
OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019
debug1: Reading configuration data /root/.ssh/config
debug1: /root/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Executing proxy command: exec ssh -tt [email protected] ssh USER@remote-server
debug1: identity file /root/.ssh/id_rsa type 0
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2
^C
root@bc9912af3ad4:~/.ssh#