OpenSSH 服务器接受公钥,然后立即关闭连接,没有任何错误消息

OpenSSH 服务器接受公钥,然后立即关闭连接,没有任何错误消息

我正在尝试连接到以前能够连接的 SSH 服务器,但使用不同的 OpenSSH 客户端版本。

Cygwin OpenSSH_6.6.1, OpenSSL 1.0.1g 7 Apr 2014客户端开始,通过使用螺旋的 Squid 代理,我可以Ubuntu 13.10 OpenSSH_6.2p2 Ubuntu-6ubuntu0.3使用转发代理成功连接到中间服务器,以绕过阻止直接访问目标服务器的防火墙。

我能够通过这个中间服务器顺利连接到其他 SSH 服务器,从而排除转发代理配置或权限问题。

我能看出与失败的目标服务器唯一的区别是,它运行的是旧的 Debian 版本,OpenSSH_4.3该版本已经好几年没有更新了,尽管几个月前我能够连接到它(在升级 heartbleed 漏洞之后的中间服务器之前)并且在升级我的 Cygwin 客户端之前。

最近的 OpenSSH 用户代理和一些较旧的 OpenSSH 用户代理之间是否存在已知的协议不兼容问题?

从中间服务器连接到目标服务器(s1.hidden.com @63.82.7.10在下面的跟踪中)失败,没有任何错误消息,并且目标服务器报告接受我转发的公钥并且中间服务器已发送该公钥。

在下面的跟踪中,与中间服务器的连接和与目标服务器的尝试连接都有选项,-vvv这些选项解释了channel 1涉及转发代理的调试消息(地址已编辑):

[...]
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp 46:83:33:00:28:48:b2:3c:b1:3f:60:bb:62:80:cc:d2
debug3: sign_and_send_pubkey: RSA 46:83:33:00:28:48:b2:3c:b1:3f:60:bb:62:80:cc:d2
debug2: channel 1: rcvd eof
debug2: channel 1: output open -> drain
debug2: channel 1: obuf empty
debug2: channel 1: close_write
debug2: channel 1: output drain -> closed
debug1: channel 1: FORCE input drain
debug2: channel 1: ibuf empty
debug2: channel 1: send eof
debug2: channel 1: input drain -> closed
debug2: channel 1: send close
Connection closed by 63.82.7.10
root@intermediate-server: ~
$ debug3: channel 1: will not send data after close
debug2: channel 1: rcvd close
debug3: channel 1: will not send data after close
debug2: channel 1: is dead
debug2: channel 1: garbage collecting
debug1: channel 1: free: authentication agent connection, nchannels 2
debug3: channel 1: status: The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 3/6 cc -1)
  #1 authentication agent connection (t4 r2 i3/0 o3/0 fd 8/8 cc -1)

在成功的目标服务器上我可以看到:

debug2: channel 1: input drain -> closed
debug2: channel 1: send close
debug1: Authentication succeeded (publickey).

在发生故障的服务器上,情况并非如此:

debug2: channel 1: input drain -> closed
debug2: channel 1: send close
Connection closed by 63.82.7.10

除 OpenSSH 版本和地址外,其他一切似乎都相同。

以下是从中间服务器到目标服务器的完整 -vvv 跟踪:

OpenSSH_6.2p2 Ubuntu-6ubuntu0.3, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /root/.ssh/config
debug1: /root/.ssh/config line 1: Applying options for s1
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to s1.hidden.com [63.82.7.10] port 2222.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2p2 Ubuntu-6ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug2: fd 3 setting O_NONBLOCK
debug3: put_host_port: [s1.hidden.com]:2222
debug3: load_hostkeys: loading entries for host "[s1.hidden.com]:2222" from file "/root/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /root/.ssh/known_hosts:4
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],ssh-rsa,[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 135/256
debug2: bits set: 507/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA b0:07:f4:ce:c7:00:e2:54:23:1c:45:7f:d9:61:41:8a
debug3: put_host_port: [63.82.7.10]:2222
debug3: put_host_port: [s1.hidden.com]:2222
debug3: load_hostkeys: loading entries for host "[s1.hidden.com]:2222" from file "/root/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /root/.ssh/known_hosts:4
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "[63.82.7.10]:2222" from file "/root/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /root/.ssh/known_hosts:5
debug3: load_hostkeys: loaded 1 keys
debug1: Host '[s1.hidden.com]:2222' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:4
debug2: bits set: 535/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: client_input_channel_open: ctype [email protected] rchan 2 win 65536 max 16384
debug2: fd 8 setting O_NONBLOCK
debug3: fd 8 is O_NONBLOCK
debug1: channel 1: new [authentication agent connection]
debug1: confirm [email protected]
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/jvincent/.ssh/id_rsa (0xb8485070),
debug2: key: /root/.ssh/id_rsa ((nil)),
debug2: key: /root/.ssh/id_dsa ((nil)),
debug2: key: /root/.ssh/id_ecdsa ((nil)),
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/jvincent/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp 46:83:33:00:28:48:b2:3c:b1:3f:60:bb:62:80:cc:d2
debug3: sign_and_send_pubkey: RSA 46:83:33:00:28:48:b2:3c:b1:3f:60:bb:62:80:cc:d2
debug2: channel 1: rcvd eof
debug2: channel 1: output open -> drain
debug2: channel 1: obuf empty
debug2: channel 1: close_write
debug2: channel 1: output drain -> closed
debug1: channel 1: FORCE input drain
debug2: channel 1: ibuf empty
debug2: channel 1: send eof
debug2: channel 1: input drain -> closed
debug2: channel 1: send close
Connection closed by 63.82.7.10
root@intermediate-server: ~
$ debug3: channel 1: will not send data after close
debug2: channel 1: rcvd close
debug3: channel 1: will not send data after close
debug2: channel 1: is dead
debug2: channel 1: garbage collecting
debug1: channel 1: free: authentication agent connection, nchannels 2
debug3: channel 1: status: The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 3/6 cc -1)
  #1 authentication agent connection (t4 r2 i3/0 o3/0 fd 8/8 cc -1)

答案1

调试这些问题的方法是获取到服务器的辅助通道/会话,然后启动 `which sshd` -d -p 2222 并检查 sshd 的输出以获取更好的信息。我的经验是:

  • 错误的 shell,请检查用户的 /etc/passwd,并检查所列用户的 shell 的权限和存在性
  • 检查 authorized_keys 中是否存在强制执行公钥的命令
  • 中的错误。轮廓 。_rc.*env 等等
  • $HOME $HOME/.ssh和上的权限错误$HOME/.ssh/authorized_keys,sshd 可能会对此很挑剔。(不过,我并不怀疑这一点,因为它显示服务器接受了密钥)

注意:您似乎已将“ssh -vv”运行到中间服务器,因为 $ 提示后的 debug*: 消息表明中间 -> 目标已退出,但现在您有一些源 -> 中间详细/调试也与您正在寻找的调试信息交织在一起。

相关内容