我尝试使用SSH ProxyCommand通过跳转框连接到服务器失败。 我的configuration如下,我运行这个命令:
ssh 10.0.2.54 -F ssh.config Host xxxx User ec2-user HostName xxxx ProxyCommand none IdentityFile /Users/me/.ssh/keys.pem BatchMode yes PasswordAuthentication no Host * ServerAliveInterval 60 TCPKeepAlive yes ProxyCommand ssh -W %h:%p -q ec2-user@xxxx ControlMaster auto ControlPersist 8h User ec2-user IdentityFile /Users/me/.ssh/keys.pem
结果很简单:
ssh_exchange_identification: Connection closed by remote host
我怎样才能解决这个问题?
谢谢,
ControlPersist与ProxyCommand结合使用效果ProxyCommand而您错过了ControlPath选项。 但这里不是问题。
首先,如果你使用的是非标准的configuration文件,你甚至希望它被代理命令使用,你甚至需要在那里指定它。 -q选项使连接安静,所以你不知道在代理命令的底层是怎么回事。 LogLevel DEBUG3选项是相当有用的。
这一行:
ProxyCommand ssh -W %h:%p -q ec2-user@xxxx
需要(你不需要上面已经指定的用户名):
ProxyCommand ssh -W %h:%p -F ssh.config xxxx
您的命令中的参数顺序也是错误的:
ssh 10.0.2.54 -F ssh.config -vv
需要是:
ssh -F ssh.config 10.0.2.54
你可以从手册页阅读。 如果使用LogLevel选项,则不需要-vv 。
那么它应该为你工作(至less它为我做了,否则调查日志)。