gpt4 book ai didi

ssh - 无法让 SSH ProxyCommand 工作(ssh_exchange_identification : Connection closed by remote host)

转载 作者:行者123 更新时间:2023-12-02 13:51:22 25 4
gpt4 key购买 nike

我尝试使用 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

我怎样才能让它工作/解决问题?

谢谢,

最佳答案

ControlPersistProxyCommand 结合使用无效,您会错过 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 - 无法让 SSH ProxyCommand 工作(ssh_exchange_identification : Connection closed by remote host),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35060642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com