0

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
4096
[root@server ~]# ulimit -Sn
1024

How do I make ulimit persist?

Elite_Dragon1337
  • 216
  • 1
  • 2
  • 10

1 Answers1

0

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.

Elite_Dragon1337
  • 216
  • 1
  • 2
  • 10
  • 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. – Michael Hampton Feb 03 '18 at 23:30