Question

How to increase SSH Connection timeout?

Hi everyone! I have an issue about SSH connection. Previously I set /etc/ssh/ssh_config as ConnectionTimeout 0 but still closes connection. So Am I missing something? How can I keep alive connection? What can I do anything else client-side? (I use Hyper.js on MacOSX) (Droplet: Ubuntu 16)

Edit: There is no timeout sFTP. While using Atom.


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.

Accepted Answer

@selcukahmet

/etc/ssh/ssh_config is the client-side configuration file not the server side config file.

To prevent all your clients from timing out, you need to edit /etc/ssh/sshd_config, which is the server-side configuration file, add these two options:

ClientAliveInterval 120
ClientAliveCountMax 720

The first one configures the server to send null packets to clients each 120 seconds and the second one configures the server to close the connection if the client has been inactive for 720 intervals that is 720*120 = 86400 seconds = 24 hours

I hope this helps.

On local computer add line on file /etc/ssh/ssh_config:

ServerAliveInterval 120

this option will ping the server every 120 seconds and keep you connected indefinitely.

I have set up the sshd_config files as shown above, and I still get logged out pretty quickly. The login to the Digital Ocean’s system production system looks much the same as the login to my development system. After being logged out by D.O. the host name in the title bar still reads D.O. The other day I was checking some files I had on my D.O. production system, validating them against my local git archives? I had expected differences as the system wasn’t behaving, but there were NO differences. Only later did I realize that D.O. must have logged me off w/o my realizing it, and I was checking against my own files. These logoffs are no joke. The virtual terminal provided by D.O. is too slow to use. Hopefully someone can give me a hand. Perhaps the tools provided by Atom will help.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.