Question

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

Edward.Ocando@gmail.com

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.

MacOS/Linux

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.