The configuration in /etc/security/limits.conf is not working at all

Hello.
I'm running openwrt 19.07 and musl 1.1.24. I wanted to have the logins limited to certain numbers of users and to do so I'm using the limits.conf file adding this:

*        hard       maxlogins       2

The problem is that configuration is not working at all. There is no file /tmp/log/utmp, I think pam is enabled to do so:

# Set up user limits from /etc/security/limits.conf.
session    required     pam_limits.so

But at the end when I try to log again with ssh, openwrt is not limiting the number of logins and I can log as much as I can and this is not what I wanted... I'd like to put a number of maximum logins.

Have any of you experienced this behavior before?
How did you solved this issue??
Am I skipping something?

Thanks in advance

  1. OpenWrt 19.07 is outdated and is no longer receiving updates. You should upgrade to a newer release.
  2. OpenWrt, by default, does not use PAM at all. If you want this to be working, you need to install the whole PAM stack along with software compiled for PAM support, like openssh-server-pam.
  3. I would nail down SSH access as far as possible - the devices OpenWrt runs on are usually not very powerful and are not designed to handle a vast amount of SSH logins. Use a VPN and/or proper firewall configuration if you want users to be able to access the device via SSH.
2 Likes

Thanks for your quick reply,

  1. I know its is outdated, but I have a lot of things backported, the motives to do this are not relevant right now.
  2. Yes I have installed openssh-server-pam and built everything with PAM support, and it is already working.
  3. Maybe it is a solution, but what I want to know if it is possible to to use the limits.conf to put that I allow for example 5 users to log in my system.