Keeping an SSH session to my Linode open

Hi,

I use Ubuntu 9.10 vmware images locally, and Ubuntu 9.10 images on Linode.

Opening a putty ssh session to my local machine will stay alive indefinately.

However, my putty connection to my Linode will die after a certain (short) period of inactivity.

This is really annoying.

I've checked 'TCPKeepAlive yes' in sshd_config is set on my Linode and it is.

Is there a different setting thats causing this to happen?

Or is it a Linode firewall thing?

11 Replies

It's probably your client. Enable keep alives in your client as well.

Adding the ClientAliveInterval option to /etc/ssh/sshd_config (and restarting sshd) may help, e.g.

ClientAliveInterval 60

@mjrich:

Adding the ClientAliveInterval option to /etc/ssh/sshd_config (and restarting sshd) may help, e.g.

ClientAliveInterval 60

Hey, thanks. I'm trying that now.

ClientAliveInterval 60 is not set in my local sshd_config file, and connection to that one is working fine.

Client is Putty.

Local server is Ubuntu 9.10 (connections stay valid forever)

Linode server is Ubuntu 9.10 (drops after ~2 mins of inactivity)

Some NATs/firewalls/etc. drop external connections that haven't responded within a set timeframe, either to conserve resources or as a security measure. Setting either ClientAliveInterval or ServerAliveInterval (depending on how many servers you have) can help.

~~[http://dan.hersam.com/2007/03/05/how-to-avoid-ssh-timeouts/" target="_blank">](http://dan.hersam.com/2007/03/05/how-to … -timeouts/">http://dan.hersam.com/2007/03/05/how-to-avoid-ssh-timeouts/](

Is your linode SSH port listening on something other than 22? That could also be why. I had that problem a while back.

Thanks @spearson and especially @mjrich.

Initially I tried ClientAliveInterval 60, but that still wasn't working.

So I set ClientAliveInterval 30 on the server. Very low I know. But it works.

Now it's consistently holding the connection open for ~20 mins. Havn't tried any longer.

Important point is that now I don't have to press "enter" every minute into my terminal while Im working LOL.

Thanks!

@fireflytech:

In Putty, under "Connection", "Seconds between keepalives (0 to turn off)", change that to "300" or so.

That will keep your session alive indefinitely without having to press "enter" or anything.

use tunnelier instead of putty..lots of features including auto-reconnect

I solved the problem by upgrading from my old Linksys router to a new Dlink router.

@BarkerJr:

I solved the problem by upgrading from my old Linksys router to a new Dlink router.
Which linksys? Some of them can be updated with new (free) firmware; I use "tomato" on my wrt54g and set the timeout to 5 days. If an ssh session is that idle then it deserves to be disconnected :-)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct