Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 03-15-2004, 09:55 AM   #1
LQ Newbie
Registered: Mar 2004
Posts: 23

Rep: Reputation: 15
limiting ssh sessions for a given user

I need to limit the number of active ssh sessions for a given user to 1.
I have tried to write /sshrc and .ssh/rc scripts that do the following:

x = w | grep 'username' | grep 'ssh' | wc -l

this lists the number of active sessions but how can i kill sessions if 1 already exists using the following: [ "$x" -ge "1" ]

Basically, I'm looking for some help coming up with a line that'll kill a ssh session.

Old 03-15-2004, 03:51 PM   #2
Registered: Sep 2003
Location: Dallas, Tx, USA
Distribution: Red Hat, Gentoo, Libranet
Posts: 98

Rep: Reputation: 16
Do a "locate pam_limits". That should find a documentation file. On my Gentoo system, it's "/usr/share/doc/pam-0.77/modules/README.pam_limits.gz", but the precise directory and version on your system may be different. (If it's not obvious, you'll have to read it with "zcat <filename> | more".)

That allows you to set the number of logins for each user. As far as I know, it doesn't care whether it's telnet, rsh, ssh, or whatever, so if for some bizarre reason you want to allow only one ssh session, but more telnet/ftp/rsh sessions, this won't help you. (Note the "ftp" in that list, by the way. It means that if someone is logged in and tries to ftp (or scp) a file to/from your machine, they'll have to log out of ssh to do it. You might want to consider making the limit 2, rather than one, for that reason.)

Hope this helps,

Old 03-16-2004, 11:20 AM   #3
LQ Newbie
Registered: Mar 2004
Posts: 23

Original Poster
Rep: Reputation: 15
Smile problem sorted

Thank you very much, problem sorted.

I located pam_limits - /usr/share/doc/packages/pam/modules/README.pam_limits on SuSE and altered the config file.



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
SSH help, concerning sessions frokid879 Linux - Newbie 4 11-11-2005 12:22 PM
Limiting SSH connectivity kaplan71 Linux - Networking 2 06-14-2005 09:35 AM
limiting ssh connection blackzone Linux - Networking 7 07-21-2004 07:22 AM
limiting concurrent TCP sessions from a single IP n3tw0rk Linux - Security 2 12-31-2003 07:56 AM
Limiting SSH access stevealarsen Linux - General 2 09-28-2002 09:18 PM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:39 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