SSH disconnects itself

Greetings and good morning.

I have a DROPLET under CentOS 8 and it is working very well. So far I have been able to install Apache and PHP, but I have a bug with SSH. When I connect through SSH it does well, but after a few seconds it automatically disconnects which forces me to connect again. This happens to me with several SSH clients and I have tried it from different computers and the error is always the same: it disconnects automatically after several seconds.

I ask for the necessary support to be able to solve this problem. Thank you very much,

Edward Ocando


If you using Putty as ssh client application do the below steps to increase keep-alive time interval. It may rectify your time out error.

Click on Connection Type 120 into “Seconds between keepalives”

Moreover, run ssh connection in debug mode, maybe you’ll get additional info. Also, do the following changes at the server end.

/etc/ssh/ssh_config ServerAliveInterval 60 ServerAliveCountMax 120

Additionally, add a rule in ssh service and in the firewall that to accept SSH request from known IP address of your networks.

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @edwardocando,

The standard workaround for this sort of problem is to make sure the router never thinks your connection is idle; send “fake traffic” at regular intervals. In computer jargon this is called “keep alive” traffic; we’re sending it just to keep the connection alive.


In your $HOME/.ssh/config file you can turn on KeepAlive with the following commands:

Host *
  ServerAliveInterval 600

This tells the ssh client that if it hasn’t received a message from the server within 600 seconds then send a NOOP message to it, to get a response. This works pretty well at making the router think the connection is still busy and so don’t drop it as idle. Nicely this packet is only sent if you are idle, so it doesn’t cause any extra traffic on active sessions.

Windows, using putty

It’s the one I use when forced to use windows! It also has the ability to send keepalives, which can be found on the Connection section of the connection menu. You can enter a timeout there, and save it as part of your connection profile.