非常奇怪的问题,SSH 立即断开连接,已完成大量调查

非常奇怪的问题,SSH 立即断开连接,已完成大量调查

我有 3 个带有相同 SD 卡的树莓派,由于某种原因,其中一个在 SSH 身份验证后突然断开连接。

该问题不会立即出现,重新启动即可修复,但不久后又再次出现。

我只在其中 1 个 pi 上看到它。使用来自另一台计算机的另一个有效密钥进行 SSH 时也会出现问题。

所以我看到:

+----[SHA256]-----+
Last login: Wed Feb 22 12:59:45 2023 from 192.168.7.93
Connection to strawberrypi.lan closed.

我知道关于这个主题有很多问题,答案也多种多样,我已经尝试了很多方法:

/etc/passwd/很好,不/bin/false

pi:x:1000:1000:,,,:/home/pi:/bin/bash

w有问题的盒子上的输出显示:

 14:24:35 up 15:07,  2 users,  load average: 0.27, 0.19, 0.19
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
pi       tty7     :0               Tue23   15:07m 49.48s  0.16s /usr/bin/lxsession -s LXDE-pi -e LXDE
pi       tty1     -                Tue23   15:07m  0.12s  0.10s -bash

这看起来没问题,因为它有一个 GUI 正在运行。

我检查了.bash_rc .profile .bash_profile等,所有 pi 都相同。

我可以执行命令并检查/var/log/auth.log

我只看到:

Feb 22 14:18:24 strawberrypi sshd[5685]: Accepted publickey for pi from 192.168.7.60 port 50331 ssh2: ED25519 SHA256:...
Feb 22 14:18:24 strawberrypi sshd[5687]: Received disconnect from 192.168.7.60 port 50331:11: disconnected by user
Feb 22 14:18:24 strawberrypi sshd[5687]: Disconnected from user pi 192.168.7.60 port 50331

另外,/var/log/messages似乎没有帮助:

Feb 22 14:16:21 strawberrypi kernel: [53976.371460] [UFW BLOCK] IN=eth0 OUT= MAC=01:00:5e:00:00:01:34:2c:c4:8a:46:69:08:00 SRC=192.168.7.1 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=39975 PROTO=2
Feb 22 14:18:26 strawberrypi kernel: [54101.533131] [UFW BLOCK] IN=eth0 OUT= MAC=01:00:5e:00:00:01:34:2c:c4:8a:46:69:08:00 SRC=192.168.7.1 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=39979 PROTO=2

我的ssh -vvvv节目:

debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Wed Feb 22 14:17:18 2023 from 192.168.7.60
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: chan_shutdown_write: channel 0: (i0 o1 sock -1 wfd 7 efd 8 [write])
debug2: channel 0: output drain -> closed
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-signal reply 0
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug2: channel 0: rcvd eow
debug2: chan_shutdown_read: channel 0: (i0 o3 sock -1 wfd 6 efd 8 [write])
debug2: channel 0: input open -> closed
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/8 sock -1 cc -1)

debug3: send packet: type 1
debug3: fd 1 is not O_NONBLOCK
Connection to strawberrypi.lan closed.
Transferred: sent 2696, received 2044 bytes, in 0.0 seconds
Bytes per second: sent 69971.5, received 53049.6
debug1: Exit status -1

SSH 配置在工作 pi 和有问题的 pi 之间是相同的。问题在一小时左右再次出现。

它的内核5.15.52-v7l+版本Raspbian GNU/Linux 11 (bullseye)

有任何想法吗?

输出sshd debug

debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: rexec_argv[2]='-p'
debug1: rexec_argv[3]='10022'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 10022 on 0.0.0.0.
Server listening on 0.0.0.0 port 10022.
debug1: Bind to port 10022 on ::.
Server listening on :: port 10022.

相关内容