I have a Centos 7 server and when I limit the maximum connections per user using the config file /etc/security/limits.conf it works just fine. See below an example of my configuration in that file:
@users - maxlogins 1
However, if the shell associated with the user is /sbin/nologin
, it does not work anymore. I created some users that are used only for port forwarding. Since I want to restrict rights for these users as much as I can, I assigned them to shell /sbin/nologin
.
also, I change these lines in /etc/ssh/sshd_config
MaxSessions 1
MaxStartups 1
but nothing happens.
So, is there a workaround for this issue? What I want is to limit the maximum connections for these users too.
Thank you in advance.
limits.conf
line withmaxsyslogins
set to 1?session required pam_limits.so
?maxsyslogins
not works and there is no option in sshd_config to control session per user.