DockerコンテナからSSHを介してリモートサーバーに接続しようとしています。 DockerコンテナはMacにあります。リモートサーバーに接続するためのすべての認証は、DockerコンテナではなくMacで行われます。
したがって、それは不可能です。
ssh -J host.docker.internal remote-server
しかし、このようにSSHコマンドをデイジーチェーン方式で接続することは可能です。
ssh -tt host.docker.internal ssh remote-server
DockerコンテナでSSH設定を編集して、次のことを簡単に実行できるようにしたいです。
ssh remote-server
一般的なガイドラインをすべて試しましたが、正しく機能しません。
興味深いことに、私が試した構成の1つは次のとおりです。
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#