Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 02-04-2009, 01:20 PM   #1
LQ Newbie
Registered: Jan 2009
Posts: 6

Rep: Reputation: 0
How to disconnect inactive ssh sessions ?

I want inactive ssh sessions to get disconnected after 5 minutes. I have configured following in sshd_config

ClientAliveInterval 100
ClientAliveCountMax 3
TCPKeepAlive no

But, the inactive session is not getting disconnected. Would appreciate help.

Old 02-04-2009, 01:41 PM   #2
Senior Member
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,093

Rep: Reputation: 197Reputation: 197
Did you restart sshd after making changes to the sshd_config?

An alternate way to do what you want if your users use ksh or bash is to use the the TMOUT option. Assign a number to that variable and the shell session is ended after that many seconds of inactivity. Set it in /etc/bashrc or suitable equivalent (/etc/bash.bashrc on SuSE systems and read the comments at the top.) To only set the variable in shell sessions resulting from ssh logins wrap the declaration in a conditional statement based upon where they logged in from using output of 'who' or something.
Old 02-04-2009, 01:44 PM   #3
LQ Newbie
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks. I have restarted sshd. I will try time out option in profile.
Old 02-04-2009, 02:28 PM   #4
LQ Newbie
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
I have tried TMOUT in profile. This works only if the user is in the shell. It didn't work if user is viewing file thru 'vi'.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
disconnect idle ssh sessions pinoyskull Linux - Newbie 19 03-02-2010 03:29 AM
defunct/inactive telnet sessions tpmadigan Linux - Enterprise 2 02-04-2008 08:56 AM
SSH disconnect, connect to process briel Linux - General 2 11-24-2006 04:32 PM
SSH on LAN - server disconnect geek745 Linux - Networking 13 02-28-2006 04:28 PM
Keep running a command when disconnect from SSH stuartornum Linux - General 3 02-17-2006 10:19 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration