要塞ホストを介したSSHトンネル

要塞ホストを介したSSHトンネル

要塞ホストを介して SSH トンネルを確立する際に問題が発生しています。

問題を解決する可能性のあるさまざまな SE の質問を調べましたが、何も解決しませんでした。

私の ssh 設定ファイル (ローカル)

Host www
    HostName ***
    IdentityFile ~/.ssh/key.pem
    ProxyCommand ssh root@bastion -W %h:%p

Host bastion
    HostName ***
    IdentityFile ~/.ssh/key.pem
    StrictHostKeyChecking      no
    ProxyCommand               none
    ForwardAgent               yes

要塞サーバー (/etc/ssh/sshd_config) に必要な構成オプションを追加しました。

PermitTunnel yes
AllowTCPForwarding yes
PermitOpen any
TCPKeepAlive yes

しかし、次のエラーが発生します。

OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: /etc/ssh/ssh_config line 59: Applying options for www
debug1: Executing proxy command: exec ssh root@bastion -W ****:22
debug1: permanently_set_uid: 0/0
debug1: permanently_drop_suid: 0
debug1: key_load_public: No such file or directory
debug1: identity file ~/.ssh/key.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file ~/.ssh/key.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
channel 0: open failed: administratively prohibited: open failed
stdio forwarding failed
ssh_exchange_identification: Connection closed by remote host

この設定には、ターゲット ホスト (www) が AWS VPC 内にあり、要塞からのみアドレス指定可能であるという注意点が 1 つあります。ルーティングは要塞から行われるため、これは問題にならないはずですが、これがこのシナリオで問題になると考えるのは間違いです。

答え1

それはかなり面倒です。AWS AMI は authorized_keys でポート転送を無効にしていることが判明しました。sshd 構成のすべてが正しいように見える場合、デバッグするのは困難でした。

~/.ssh/承認済みキー

no-port-forwarding,no-agent-forwarding,no-X11-forwarding

関連情報