Ulimit settings not being applied with SSH logins

On a RHEL5 server ulimit setting was not applied when I logged in using SSH. No matter what I did the setting remained the same. Doing a “su – ” to a user, however, worked like a treat. Strange! I did a bit of googling and found the following answer to my problem:

1. In /etc/pam.d/sshd add the line

session    required     pam_limits.so

2. In /etc/pam.d/login add the line

session    required     pam_limits.so

3. In /etc/ssh/sshd_config add

UsePAM yes

(this might already be in place in your config file – I’m not using a stock sshd_config)

4. reload SSH

/etc/init.d/sshd restart

Now change something in /etc/security/limits.conf

user1           soft    nofile  2048
user1           hard    nofile  4096

Log in as user1 – and voila!
ulimit -n should now show 2048 and ulimit -nH 4096


  1. Rick Hunter says:

    Thank you so much, I have been messing with this exact same issue for some time now. Step 3 was the key I had been looking for.

  2. Bob Sommerville says:

    This is the one piece (step 3) of the puzzle that is NOT documented by Redhat or even Oracle.
    Huge thanks!

  3. Zulu King says:

    Thanks a lot Man … Very Usefull … :)

Leave a Reply