How to Keep Your SSH Terminal Connected and from Being Automatically Disconnected by the Remote Computer

You can share this, including by text message!

  • How to Keep Your SSH Terminal Connected and from Being Automatically Disconnected by the Remote Computer

Don’t you just hate it when you are connected to a remote computer system via ssh, and you do something in another window, only to find when you return to your ssh session that you’ve been automatically disconnected by the remote system, and you have to log in all over again? Here’s how make it so that you can stay connected to the remote computer with ssh no matter how long you are idle.

First, you will need to find your ssh configuration file; if you don’t have one, you will need to create it.

On a Mac, for example, your personal ssh configuration file is at:

~/.ssh/config

If you want to create this change for the entire computer (including other users), you will instead want to use the file found at /etc/ssh/ssh_config

 
(Article continues below)
Get notified of new Internet Patrol articles for free!
Or Read Internet Patrol Articles Right in Your Inbox!
as Soon as They are Published! Only $1 a Month!

Imagine being able to read full articles right in your email, or on your phone, without ever having to click through to the website unless you want to! Just $1 a month and you can cancel at any time!
How to Keep Your SSH Terminal Connected and from Being Automatically Disconnected by the Remote Computer

On other types of computers, you can find the ssh configuration file in similar locations (and the individual user file is almost always going to be at ~/.ssh/config).

Now, make a backup copy of the file, just to be safe.

Then edit the actual file to include this simple line:

ServerAliveInterval 300

No Paywall Here! The Internet Patrol is and always has been free. We don't hide our articles behind a paywall, or restrict the number of articles you can read in a month if you don't give us money. That said, it does cost us money to run the site, so if something you read here was helpful or useful, won't you consider donating something to help keep the Internet Patrol free?
Click for amount options
Other Amount:

That’s it!

Now your computer will let the remote server know, every X seconds, that your computer is still there and should not be connected. The number in that line is the number of seconds – in the example above it’s 300 seconds, or five minutes. You may need to adjust the number to suit your own needs, but 300 is usually sufficient.

That’s all there is to it!

  
No Paywall Here!
The Internet Patrol is and always has been free. We don't hide our articles behind a paywall, or restrict the number of articles you can read in a month if you don't give us money. That said, it does cost us money to run the site, so if something you read here was helpful or useful, won't you consider donating something to help keep the Internet Patrol free? Thank you!

How to Keep Your SSH Terminal Connected and from Being Automatically Disconnected by the Remote Computer

Get notified of new Internet Patrol articles!

You can share this, including by text message!

  • How to Keep Your SSH Terminal Connected and from Being Automatically Disconnected by the Remote Computer

Leave a Reply

Your email address will not be published. Required fields are marked *