
AWS に Bastion Host を設定しています (詳細はこちらをご覧ください:https://www.nadeau.tv/ssh-with-a-bastion-host/) を作成して、AWS にある他の EC2 インスタンスに安全にアクセスできるようにしました。
要塞ホスト経由でプロキシしようとすると、いくつかの問題が発生します。
私の SSH 構成ファイルは次のとおりです:
# Bastion Host
Host bastion
User ec2-user
Hostname XX.XX.XX.XXX
IdentityFile ~/.ssh/keys/bastion.pem
# EC2 Instance
Host 172.*
User ec2-user
IdentityFile ~/.ssh/keys/bastion.pem
ProxyCommand ssh bastion -W %h:%p
以下はコマンドラインからの詳細出力です。
Jeff-Bezos-iMac:tmp jeff$ ssh 172.xx.x.xx -v
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/jeff/.ssh/config
debug1: /Users/jeff/.ssh/config line 9: Applying options for 172.*
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Executing proxy command: exec ssh bastion -W 172.xx.x.xx:22
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jeff/.ssh/keys/bastion.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jeff/.ssh/keys/bastion.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: permanently_drop_suid: 503
channel 0: open failed: connect failed: Connection timed out
stdio forwarding failed
ssh_exchange_identification: Connection closed by remote host
'stdio forwarding failed' というエラーが発生して行き詰まっています。助けていただければ幸いです。
よろしく
答え1
SSH セキュリティ グループが正しく構成されていませんでしたが、Bastion Server のプライベート IP からの着信 SSH 要求を受け入れるように変更したところ、すべてが期待どおりに動作しました。
答え2
私の場合、Bastion/Jumpbox ホストはホスト名を解決できませんでした (IP ではなくホスト名を使用しました)。私の場合、それは DNS 設定の DNS エントリが間違っていたため、Bastion ホストが ssh 構成ファイルで使用しているのと同じ名前に解決できることを確認してください。
答え3
Bastion Host で を設定し、再起動AllowTcpForwarding yes
( )すると、接続の問題が解決しました。/etc/ssh/sshd_config
sshd
systemctl restart sshd.service