无法让 SSH ProxyCommand 工作(ssh_exchange_identification:连接被远程主机关闭)
Can't get SSH ProxyCommand to work (ssh_exchange_identification: Connection closed by remote host)
我尝试使用 SSH ProxyCommand 通过跳转框连接到服务器时未成功。我的配置如下,我是 运行 这个命令:
ssh 10.0.2.54 -F ssh.config -vv
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 ec2-user@x.x.x.x
ControlMaster auto
ControlPersist 8h
User ec2-user
IdentityFile /Users/me/.ssh/keys.pem
结果是:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data ssh.config
debug1: ssh.config line 9: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/Users/me/.ssh/mux-ec2-user@10.0.2.54:22" does not exist
debug2: ssh_connect: needpriv 0
debug1: Executing proxy command: exec ssh -W 10.0.2.54:22 -q ec2-user@x.x.x.x
debug1: identity file /Users/me/.ssh/keys.pem type -1
debug1: identity file /Users/me/.ssh/keys.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: permanently_drop_suid: 501
我怎样才能解决这个 work/troubleshoot 问题?
谢谢,
ControlPersist
与 ProxyCommand
结合使用无效,您错过了 ControlPath
选项。不过这里不是问题。
首先,如果您使用的是非标准配置文件,并且您希望它甚至被代理命令使用,您也需要在那里指定它。 -q
选项使连接安静,因此您不知道代理命令背后发生了什么。 LogLevel DEBUG3
选项很有用。
这一行:
ProxyCommand ssh -W %h:%p -q ec2-user@x.x.x.x
需要(并且您不需要用户名,因为它已在上面指定):
ProxyCommand ssh -W %h:%p -F ssh.config x.x.x.x
您的命令中的参数顺序也有误:
ssh 10.0.2.54 -F ssh.config -vv
需要:
ssh -F ssh.config 10.0.2.54
正如您可以从手册页中看到的那样。如果您使用 LogLevel
选项,则不需要 -vv
。
那么它应该对你有用(至少对我有用,否则请调查日志)。
我尝试使用 SSH ProxyCommand 通过跳转框连接到服务器时未成功。我的配置如下,我是 运行 这个命令:
ssh 10.0.2.54 -F ssh.config -vv
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 ec2-user@x.x.x.x
ControlMaster auto
ControlPersist 8h
User ec2-user
IdentityFile /Users/me/.ssh/keys.pem
结果是:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data ssh.config
debug1: ssh.config line 9: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/Users/me/.ssh/mux-ec2-user@10.0.2.54:22" does not exist
debug2: ssh_connect: needpriv 0
debug1: Executing proxy command: exec ssh -W 10.0.2.54:22 -q ec2-user@x.x.x.x
debug1: identity file /Users/me/.ssh/keys.pem type -1
debug1: identity file /Users/me/.ssh/keys.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: permanently_drop_suid: 501
我怎样才能解决这个 work/troubleshoot 问题?
谢谢,
ControlPersist
与 ProxyCommand
结合使用无效,您错过了 ControlPath
选项。不过这里不是问题。
首先,如果您使用的是非标准配置文件,并且您希望它甚至被代理命令使用,您也需要在那里指定它。 -q
选项使连接安静,因此您不知道代理命令背后发生了什么。 LogLevel DEBUG3
选项很有用。
这一行:
ProxyCommand ssh -W %h:%p -q ec2-user@x.x.x.x
需要(并且您不需要用户名,因为它已在上面指定):
ProxyCommand ssh -W %h:%p -F ssh.config x.x.x.x
您的命令中的参数顺序也有误:
ssh 10.0.2.54 -F ssh.config -vv
需要:
ssh -F ssh.config 10.0.2.54
正如您可以从手册页中看到的那样。如果您使用 LogLevel
选项,则不需要 -vv
。
那么它应该对你有用(至少对我有用,否则请调查日志)。