How to restrict the maximum simultaneous ssh logins from a specific user on AlmaLinux, CentOS

  • There should be pam_limits.conf module present in /etc/pam.d/system-auth. On older systems, this entry must also be in system-auth and password-auth files.

grep limit /etc/pam.d/system-auth
session required

  • Add maxlogins entry in /etc/security/limits.conf as follows:

username hard maxlogins 'number of max logins'

  • Enable PAM in /etc/ssh/sshd_config file as follows:

UsePAM yes

Leave a Reply