Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to prevent my ssh users from having more than one session open at once, my system is Ubuntu 11.10.

I thought the setting was in /etc/security/limits.conf where I set the following:

betatest hard maxlogins 1

However, this has no effect and I can log in multiple times using user account name betatest from different machines.

The sshd_config is using PAM and the login and sshd configs in /etc/pam.d both have the setting:

session    required   pam_limits.so

If anyone knows how I can restrict the concurrent sessions on a per user basis I would really appreciate the help.

share|improve this question
Do you think it might be possible to have a PAM module written to check if the user attempting to login is already logged in and if they are then stop them logging in again? I don't have the skills for this but if it's possible then at least I have a starting point. –  Kyoku Mar 9 '12 at 15:49

1 Answer 1

Per user setting is very tricky, you might have to write some wrapper script for this. SSHD config has an option MaxSessions which limits no of connections per ip.

share|improve this answer
The risk is the user will share the login details with friends on different IP's, that's the main issue I'm trying to avoid. –  Kyoku Mar 9 '12 at 5:11
Then proy answer about ssh MaxSessions is your answer –  Gabor Vincze Mar 9 '12 at 7:16
MaxSessions only limits per ip basis; so it seems will not work –  Ajo Augustine Mar 9 '12 at 8:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.