SSH登录后退出,可能原因是什么/如何调试?

SSH登录后退出,可能原因是什么/如何调试?

我当前通过 ssh 连接到服务器(10.2),但是当我再次尝试 ssh 到服务器时,它总是connection closed

$ ssh -vvv [email protected] 
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/kyz/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "10.2" port 22
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffiedebug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
om,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffiedebug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected]: compression ctos: none,[email protected]
debug2: reserved 0 
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:F+ixWaVGWbpF3x/x6X7ArfGCX1KV8XFpXFdTwbPa5ew
debug3: hostkeys_foreach: reading file "/home/kyz/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/kyz/.ssh/known_hosts:72
debug3: load_hostkeys: loaded 1 keys from 10.2
debug3: hostkeys_foreach: reading file "/home/kyz/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/kyz/.ssh/known_hosts:73
debug3: load_hostkeys: loaded 1 keys from 10.0.0.2
debug1: Host '10.2' is known and matches the ECDSA host key.
debug1: Found key in /home/kyz/.ssh/known_hosts:72
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: /home/kyz/.ssh/id_rsa (0x55d85774b100), agent
debug2: key: /home/kyz/.ssh/id_dsa ((nil))
debug2: key: /home/kyz/.ssh/id_ecdsa ((nil))
debug2: key: /home/kyz/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
Connection closed by 10.0.0.2 port 22

$ ssh -vvv 10.2
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/kyz/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "10.2" port 22
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9
debug1: SSH2_MSG_KEXINIT sent
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
om,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffiedebug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug1: kex: algorithm: curve25519-sha256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:F+ixWaVGWbpF3x/x6X7ArfGCX1KV8XFpXFdTwbPa5ew
debug3: hostkeys_foreach: reading file "/home/kyz/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/kyz/.ssh/known_hosts:72
debug3: load_hostkeys: loaded 1 keys from 10.2
debug3: hostkeys_foreach: reading file "/home/kyz/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/kyz/.ssh/known_hosts:73
debug3: load_hostkeys: loaded 1 keys from 10.0.0.2
debug1: Host '10.2' is known and matches the ECDSA host key.
debug1: Found key in /home/kyz/.ssh/known_hosts:72
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: /home/kyz/.ssh/id_rsa (0x55e7b3e58100), agent
debug2: key: /home/kyz/.ssh/id_dsa ((nil))
debug2: key: /home/kyz/.ssh/id_ecdsa ((nil))
debug2: key: /home/kyz/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
Connection closed by 10.0.0.2 port 22

主目录以正确的权限存在,/etc/passwd也指向正确的主目录并且/bin/bash存在且可执行。

当 ssh 尝试时服务器上的 Journalctl:

Feb 16 19:26:48 f9988 audit[32203]: SECCOMP auid=4294967295 uid=99 gid=99 ses=4294967295 pid=32203 comm="sshd" exe="/usr/bin/sshd" sig=31 arch=c000003e syscall=230 compat=0 ip=0x7fb92538427e code=0x0
Feb 16 19:26:48 f9988 audit[32203]: ANOM_ABEND auid=4294967295 uid=99 gid=99 ses=4294967295 pid=32203 comm="sshd" exe="/usr/bin/sshd" sig=31 res=1
Feb 16 19:26:48 f9988 kernel: audit: type=1326 audit(1581856008.775:6156): auid=4294967295 uid=99 gid=99 ses=4294967295 pid=32203 comm="sshd" exe="/usr/bin/sshd" sig=31 arch=c000003e syscall=230 compat=0 ip=0x7fb92538427e code=0x0
Feb 16 19:26:48 f9988 kernel: audit: type=1701 audit(1581856008.775:6157): auid=4294967295 uid=99 gid=99 ses=4294967295 pid=32203 comm="sshd" exe="/usr/bin/sshd" sig=31 res=1

配置/etc/ssh/sshd_config有:

AuthorizedKeysFile      .ssh/authorized_keys
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no # pam does that
Subsystem       sftp    /usr/lib/ssh/sftp-server

服务器的ssh版本OpenSSH_7.9p1, OpenSSL 1.1.1a 20 Nov 2018

我还应该检查哪些其他日志来了解哪个部分导致此问题?

编辑显然,在完全升级(pacman -Syu)之后,一切都开始正常工作,问题的可能原因是我卸载了xorg-server以及其他一些东西

相关内容