LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 03-15-2004, 08:55 AM   #1
breenbaron
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.

Thanks.
 
Old 03-15-2004, 02:51 PM   #2
clacour
Member
 
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,

CHL
 
Old 03-16-2004, 10:20 AM   #3
breenbaron
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.

Cheers.
 
  


Reply


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


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

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