Using CentOS 6.6

In /etc/security/limits.conf I have set the following:

* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535

In etc/security/limits.d/90-nproc.conf I have set this:

*          soft    nproc     65535
root       soft    nproc     unlimited
*          soft    nofile    65535
root       soft    nofile    65535
*          hard    nofile    65535
root       hard    nofile    65535

Yet for some reason when I log out and log in to SSH as root (passwordless login using ssh key):

[root@server ~]# ulimit -Hn
[root@server ~]# ulimit -Sn

How do I make ulimit persist?


Turns out it was because I was using UsePAM no in /etc/ssh/sshd_config.

For some reason, every tutorial online recommends disabling PAM in order to disable password logins without a key. After doing some research, it seems this is terrible advice and I'm not sure why it is recommended by so many tutorials.

With PAM disabled, pam_limits module is never run causing the limits to never be read from the limits.conf file.

  • 2
    Red Hat even left a comment in sshd_config advising not to set UsePam no. I can't understand why so many tutorials on the Internet are so bad. Feb 3 '18 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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