How to prevent ssh from reseting the connection

If you want to prevent ssh from resetting the connection when no data is sent during X seconds, you have two options:

  • configure your ssh on the server and increase the value of “ClientAliveInterval 1800
    1. edit /etc/ssh/shh_config and add the following line if it does not exist: ” ClientAliveInterval 1800″
      (note: I’ve put 1800 to allow 30 minutes (1800 sec) without data communication prior to closing the connection, but you can put any value you want (0 = no timeout))
    2. restart ssh: sudo /etc/init.d/sshd restart
  • or configure your ssh on the client (but you will need to do it on all client machines you connect with). Same procedure except that variable name is now “ServerAliveInterval” and you don’t have any sshd to restart.
    1. edit /etc/ssh/ssh_config and add the following line “ServerAliveInterval 120
      note: this will make ssh send data packet every 120 seconds to avoid closing the connection
    2. reopen your ssh connection

sources

Post a Comment

Your email is never published nor shared. You're allow to say what you want...