I cannot stay connected in SSH session and randomly get the error: ssh client_loop: send disconnect: Connection reset by peer

Q. I use SSH to login to my server and I randomly find my shell session disconnected with the message: "ssh client_loop: send disconnect: Connection reset by peer" or "Connection reset by" What is causing the "Broken Pipe" message and how can I avoid it and stay connected?

 

A. Most likely your client ssh config is set with "TCPKeepAlive yes" - which means your client will send a TCPKeepAlive request message to the server and must get a reply or it assumes the peer is gone and disconnects your session. This would be a common thing on a flaky connection such as a Satellite or Wireless connection. Any easy fix should be to set TCPKeepalive no and set a reasonable ServerAliveInterval, Setting TCPKeepAlive no means the connection will be presumed good until it is otherwise interrupted- which means temporary pauses (such as changing cellular towers) should allow your session to stay active, even if it is idling in the background.

On your client side simply edit ~/.ssh/config  and include:

Host *
    ServerAliveInterval 20
    TCPKeepAlive no



This is not a substitute for a stable connection, but this should allow you to no longer get the random disconnects as frequently.

  • SSH, Connection reset by peer
  • 23 Kunder som kunne bruge dette svar
Hjalp dette svar dig?