使用堡垒主机的 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 安全组,当它被更改为接受来自 Bastion Server 的私有 IP 的传入 SSH 请求时,一切都按预期工作。

答案2

就我而言,Bastion/Jumpbox 主机无法解析主机名(我使用的是主机名而不是 IP),因此就我而言,这是我的 DNS 设置中的一个错误 DNS 条目,因此只需确保 Bastion 主机可以解析为您在 ssh 配置文件中使用的相同名称。

答案3

我在 Bastion Host 中设置了,重新启动了AllowTcpForwarding yes(),它为我解决了连接问题。/etc/ssh/sshd_configsshdsystemctl restart sshd.service

相关内容