Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Say someone starts a SSH session through Putty to a CentOS box, and they leave it sit idle for a while. Where can I set an idle timeout so it will disconnect any sessions idle for a certain time period?
In the /etc/ssh/sshd_config file, uncomment and change the ClientAliveInterval, then restart the sshd services. According to the MAN page of sshd_config:
ClientAliveInterval
Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message
through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will
not be sent to the client. This option applies to protocol version 2 only.
ClientAliveInterval 60 would drop the connection after 60 seconds of inactivity.
Looking on some older servers, I don't see that option set but they do disconnect. Was that maybe enabled by default or something in older versions of ssh?
ok, because looking at another server, I don't see that setting configured in the main config file, and in the user's ~/.ssh/ I don't see a config file. I think I'm either missing something, or maybe there's another way to cause a similar outcome? or it was just a default setting in older versions that did it no matter what, which is why I can't find it. not a big deal, i'm just confused.
Ah ok, so it's only the global setting in the main config file then. Still makes me wonder why other older servers will disconnect an idle ssh session if they don't have that set. Maybe there's a different setting out there that disconnect any idle connect (not connection type specific).
maybe it's the shell killing the session on those other servers. I'm going to test it again, but on this new server, I don't think it's killing sessions either with only ClientAliveInterval set. maybe i need to enable another setting in there that goes with it.
I'll post back if i've gone crazy and idle sessions actually are killed with just that setting
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.