Idle ssh users

A.Fadyushin at it-centre.ru A.Fadyushin at it-centre.ru
Fri Jan 27 16:48:38 UTC 2006


If your users are using bash as their shell and just forget to log out
after they no longer need a shell session (so the shell is still waiting
for the user to enter something at the command prompt) you can use the
bash's environment variable TMOUT. That variable contains the number of
second which bash will wait for the user to enter the command at the
prompt. If the sessions is idle (at the command prompt) for that number
of seconds bash will terminate and the user will be logged out. This
variable could be set in global or per user .profile files. Of course,
the users can reset this value if they need a longer period of waiting
at the command prompt so this limit can not be strictly enforced by the
system administrator. However, the users who forget to log out most
probably will forget to change this value also.

Alexey Fadyushin
Brainbench MVP for Linux.
http://www.brainbench.com

> -----Original Message-----
> From: redhat-install-list-bounces at redhat.com
[mailto:redhat-install-list-
> bounces at redhat.com] On Behalf Of Rick Stevens
> Sent: Thursday, January 26, 2006 10:17 PM
> To: Getting started with Red Hat Linux
> Subject: Re: Idle ssh users
> 
> On Thu, 2006-01-26 at 11:22 -0700, redhat at buglecreek.com wrote:
> > On occasion we have have people login via ssh to some of our RH
linux
> > systems and they do not log out.  When doing a "w" or
> > "who" we see idle connections for days sometimes.  What is the
> > recommended way to log these users out?  Is there a better way than
just
> > killing the users ssh process?
> 
> Not really.  You can write a script that parses the output of the
"last"
> or "who" commands and kills off the processes involved.  For example:
> 
>     #!/bin/bash
>     PATH=$PATH;/usr/bin;/bin
>     WHOLIST=`who -u`
>     for LINE in $WHOLIST; do
> 	echo $LINE | awk '{if (index($6, "old")) system("kill "$7);}'
>     done
> 
> would kill any user's login process that had been idle for over a day.
> I'd set that up as a shell script and run a cron job for it every, oh,
> four hours or so, depending on what you want to do.
> 
> See "info who" for details on the "-u" option.
> 
> ----------------------------------------------------------------------
> - Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
> - VitalStream, Inc.                       http://www.vitalstream.com -
> -                                                                    -
> -  You know the old saying--any technology sufficiently advanced is  -
> -               indistinguishable from a Perl script                 -
> -                                 --Programming Perl, 2nd Edition    -
> ----------------------------------------------------------------------
> 
> _______________________________________________
> Redhat-install-list mailing list
> Redhat-install-list at redhat.com
> https://www.redhat.com/mailman/listinfo/redhat-install-list
> To Unsubscribe Go To ABOVE URL or send a message to:
> redhat-install-list-request at redhat.com
> Subject: unsubscribe




More information about the Redhat-install-list mailing list