LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   limiting ssh sessions for a given user (https://www.linuxquestions.org/questions/linux-security-4/limiting-ssh-sessions-for-a-given-user-157932/)

breenbaron 03-15-2004 08:55 AM

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.

clacour 03-15-2004 02:51 PM

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

breenbaron 03-16-2004 10:20 AM

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.


All times are GMT -5. The time now is 04:02 AM.