Since upgrading from CentOS 7 to Rocky Linux 8 our PAM maxlogins
limit is no longer being enforced for SFTP sessions.
SFTP users belong to the sftp
group and we have this in /etc/security/limits.d/10-maxlogins.conf
@sftp - maxlogins 1
We use internal-sftp
for SFTP sessions and have this in /etc/ssh/sshd_config
Subsystem sftp internal-sftp -l INFO
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
However, users are still managing to open > 1 concurrent SFTP sessions. Should we be doing anything different in EL8 to enforce these limits?
PAM debug logs below show it’s reading the relevant config files. However, the limit is not enforced.
Apr 10 16:13:04 sftp-test sshd[40955]: Accepted password for sftptest from 10.3.200.146 port 60976 ssh2
Apr 10 16:13:04 sftp-test sshd[40955]: pam_limits(sshd:session): reading settings from '/etc/security/limits.conf'
Apr 10 16:13:04 sftp-test sshd[40955]: pam_limits(sshd:session): reading settings from '/etc/security/limits.d/10-max-logins.conf'
Apr 10 16:13:04 sftp-test sshd[40955]: pam_limits(sshd:session): checking if sftptest is in group sftp
Apr 10 16:13:04 sftp-test sshd[40955]: pam_limits(sshd:session): process_limit: processing - maxlogins 1 for GROUP
Apr 10 16:13:04 sftp-test sshd[40955]: pam_limits(sshd:session): checking logins for 'sftptest' (maximum of 1)
Apr 10 16:13:04 sftp-test systemd[40960]: pam_unix(systemd-user:session): session opened for user sftptest(uid=1000) by sftptest(uid=0)
Apr 10 16:13:04 sftp-test sshd[40955]: pam_unix(sshd:session): session opened for user sftptest(uid=1000) by sftptest(uid=0)
Apr 10 16:13:26 sftp-test sshd[40986]: Accepted password for sftptest from 10.3.200.146 port 52110 ssh2
Apr 10 16:13:26 sftp-test sshd[40986]: pam_limits(sshd:session): reading settings from '/etc/security/limits.conf'
Apr 10 16:13:26 sftp-test sshd[40986]: pam_limits(sshd:session): reading settings from '/etc/security/limits.d/10-max-logins.conf'
Apr 10 16:13:26 sftp-test sshd[40986]: pam_limits(sshd:session): checking if sftptest is in group sftp
Apr 10 16:13:26 sftp-test sshd[40986]: pam_limits(sshd:session): process_limit: processing - maxlogins 1 for GROUP
Apr 10 16:13:26 sftp-test sshd[40986]: pam_limits(sshd:session): checking logins for 'sftptest' (maximum of 1)
Apr 10 16:13:26 sftp-test sshd[40986]: pam_unix(sshd:session): session opened for user sftptest(uid=1000) by sftptest(uid=0)