與堡壘主機的 SSH - stdio 轉送失敗

與堡壘主機的 SSH - stdio 轉送失敗

我正在 AWS 上設定堡壘主機(這裡有一些詳細資訊: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 轉發失敗”,感謝任何幫助。

問候

答案1

我沒有正確配置 SSH 安全性群組,當將其更改為接受來自堡壘伺服器的私人 IP 的傳入 SSH 請求時,一切都按預期工作。

答案2

就我而言,Bastion/Jumpbox 主機無法解析主機名稱(我使用主機名稱而不是IP),因此在我的情況下,這是我的DNS 設定中的錯誤DNS 條目,因此只需確保Bastion 主機可以解析為與您在 ssh 設定檔中使用的名稱相同。

答案3

我在 Bastion Host 中設置,重新啟動AllowTcpForwarding yes( ) ,它為我解決了連接問題。/etc/ssh/sshd_configsshdsystemctl restart sshd.service

相關內容