I'm trying to figure out why I keep getting disconnected from my SSH session. The host is a CentOS server and the clients are MacOS.
The error seems to be sporadic - sometimes it's once an hour, other times it's several times in a minute. But what's interesting is that this doesn't just happen when I don't use the connection - I can literally be typing and the connection will go. The error is:
ssh_dispatch_run_fatal: Connection to x.x.x.x port 2020: Connection corrupted
I have also tried having multiple tabs open with an ssh connection open in each and they seem to disconnect at the same time.
Turning debug level 3 on, I have the /var/log/secure
output here surrounding the time of a disconnect:
Feb 16 08:06:08 46 sshd[2864]: debug2: channel 0: request [email protected] confirm 1
Feb 16 08:06:08 46 sshd[2864]: debug3: send packet: type 98
Feb 16 08:06:08 46 sshd[2864]: debug3: receive packet: type 100
Feb 16 08:06:08 46 sshd[2864]: debug1: Got 100/121 for keepalive
Feb 16 08:06:38 46 sshd[2864]: debug2: channel 0: request [email protected] confirm 1
Feb 16 08:06:38 46 sshd[2864]: debug3: send packet: type 98
Feb 16 08:06:38 46 sshd[2864]: debug3: receive packet: type 100
Feb 16 08:06:38 46 sshd[2864]: debug1: Got 100/122 for keepalive
Feb 16 08:06:51 46 sshd[4517]: Connection closed by x.x.x.x port 62073
Feb 16 08:06:51 46 sshd[4517]: debug1: channel 0: free: server-session, nchannels 1
Feb 16 08:06:51 46 sshd[4517]: debug3: channel 0: status: The following connections are open:\r\n #0 server-session (t4 r0 i0/0 o0/0 fd 12/8 cc -1)\r\n
Feb 16 08:06:51 46 sshd[4517]: Close session: user my_username from x.x.x.x port 62073 id 0
Feb 16 08:06:51 46 sshd[4517]: debug3: mm_request_send entering: type 30
Feb 16 08:06:51 46 sshd[4517]: debug3: session_unused: session id 0 unused
Feb 16 08:06:51 46 sshd[4517]: debug1: do_cleanup
Feb 16 08:06:51 46 sshd[4517]: debug3: PAM: sshpam_thread_cleanup entering
Feb 16 08:06:51 46 sshd[4517]: debug3: mm_request_send entering: type 122
Feb 16 08:06:51 46 sshd[4517]: debug3: mm_request_receive_expect entering: type 123
Feb 16 08:06:51 46 sshd[4517]: debug3: mm_request_receive entering
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_request_receive entering
Feb 16 08:06:51 46 sshd[4514]: debug3: monitor_read: checking request 30
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_answer_pty_cleanup entering
Feb 16 08:06:51 46 sshd[4514]: debug1: session_by_tty: session 0 tty /dev/pts/1
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_session_close: session 0 pid 4517
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_session_close: tty /dev/pts/1 ptyfd 4
Feb 16 08:06:51 46 sshd[4514]: debug1: session_pty_cleanup: session 0 release /dev/pts/1
Feb 16 08:06:51 46 sshd[4514]: debug3: session_unused: session id 0 unused
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_request_receive entering
Feb 16 08:06:51 46 sshd[4514]: debug3: monitor_read: checking request 122
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_request_send entering: type 123
Feb 16 08:06:51 46 sshd[4517]: debug3: mm_request_send entering: type 124
Feb 16 08:06:51 46 sshd[4517]: Transferred: sent 1503792, received 18928 bytes
Feb 16 08:06:51 46 sshd[4517]: Closing connection to x.x.x.x port 62073
Feb 16 08:06:51 46 sshd[4517]: debug3: mm_audit_event entering
Feb 16 08:06:51 46 sshd[4517]: debug3: mm_request_send entering: type 112
Feb 16 08:06:51 46 sshd[4517]: debug3: mm_request_send entering: type 50
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_request_receive entering
Feb 16 08:06:51 46 sshd[4514]: debug3: monitor_read: checking request 124
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_request_receive entering
Feb 16 08:06:51 46 sshd[4514]: debug3: monitor_read: checking request 112
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_answer_audit_event entering
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_request_receive entering
Feb 16 08:06:51 46 sshd[4514]: debug3: monitor_read: checking request 50
Feb 16 08:06:51 46 sshd[4514]: debug3: mm_answer_term: tearing down sessions
Feb 16 08:06:51 46 sshd[4514]: debug1: PAM: cleanup
Feb 16 08:06:51 46 sshd[4514]: debug1: PAM: closing session
Feb 16 08:06:51 46 sshd[4514]: pam_unix(sshd:session): session closed for user my_username
Feb 16 08:06:51 46 sshd[4514]: debug1: PAM: deleting credentials
Parts are obfuscated with x
or my_username
Update
I've added a new set of logs above - less than originally but I'm hoping the applicable ones. The new line:
Feb 16 08:06:51 46 sshd[4517]: Connection closed by x.x.x.x port 62073
interests me. Would this suggest that my device is making the disconnect and it's not SSH related? I see (I think) successful keep-alive packets being sent right before the disconnect.
I've tried restarting the daemon, and using the OpenSSH (via brew) version of SSH on the Mac and that's made no difference.
Server info:
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-02-11 10:21:40 GMT; 1h 52min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 6271 (sshd)
CGroup: /system.slice/sshd.service
└─6271 /usr/sbin/sshd -D
The only differences in our sshd_config
to the standard CentOS one is the port, log level and:
ClientAliveInterval 30
ClientAliveCountMax 5
Why am I getting disconnected? What could be causing the connection to be corrupted?