大网数据广告活动
服务器运维问答

Can't get SSH ProxyCommand to work (ssh_exchange_identification: Connection closed by remote host)

· 52CE 我爱测

I'm unsuccessfully trying to use SSH ProxyCommand to connect to a server via a jump box. My config is below, I'm running this command: ssh 10.0.2.54 -F ssh.config Host x.x.x.x User ec2-user HostName x.x.x.x ProxyCommand none Iden…

问题原文

原帖链接 · rix · CC BY-SA 3.0

I'm unsuccessfully trying to use SSH ProxyCommand to connect to a server via a jump box. My config is below, I'm running this command:

ssh 10.0.2.54 -F ssh.config

Host x.x.x.x
    User                   ec2-user
    HostName               x.x.x.x
    ProxyCommand           none
    IdentityFile           /Users/me/.ssh/keys.pem
    BatchMode              yes
    PasswordAuthentication no

Host *
    ServerAliveInterval    60
    TCPKeepAlive           yes
    ProxyCommand           ssh -W %h:%p -q [email omitted]
    ControlMaster          auto
    ControlPersist         8h
    User                   ec2-user
    IdentityFile           /Users/me/.ssh/keys.pem

The result is simply:

ssh_exchange_identification: Connection closed by remote host

How can I get this to work/troubleshoot the issue?

Thanks,

已采纳解答

原帖链接 · Jakuje · CC BY-SA 3.0

ControlPersist in combination with ProxyCommand is not effective and you miss ControlPath option. But it is not a problem here.

First of all, if you are using non-standard config file and you want it to be used even by the proxy command, you need to specify it even there. The -q option makes the connection quiet so you have no idea what is going on under the hood of the proxy command. LogLevel DEBUG3 option is quite useful.

This line:

ProxyCommand           ssh -W %h:%p -q [email omitted]

needs to be (and you don't need the username as it is already specified above):

ProxyCommand           ssh -W %h:%p -F ssh.config x.x.x.x

You have also wrong order of parameters in your command:

ssh 10.0.2.54 -F ssh.config -vv

needs to be:

ssh -F ssh.config 10.0.2.54

as you can read from manual page. And -vv is not needed if you use LogLevel option.

Then it should work for you (at least it did for me, otherwise investigate the log).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。