Running remote ssh and ulimit command

I have the following script:

cat > /tmp/script.sh <<EndOfScript
#!/bin/sh
ulimit -n 8192
run_app
EndOfScript

which runs smoothly locally, it is always in order. But if I try to run it remotely via ssh:

scp /tmp/script.sh user@host:/tmp/script.sh
ssh user@host "chmod 755 /tmp/script.sh; /tmp/script.sh"

I got an error:

ulimit: open files: cannot modify limit: Operation not permitted

I also tried the following command:

ssh user@host "ulimit -n 8192"

same mistake.

It seems that executing the remote ssh command provides a limitation of the 1024 hard drive on the nofile sheet, but I cannot find out how to change this default value. I tried changing /etc/security/limits.conf and restarting sshd, still the same error.

+5
source share
4 answers

Fiannly calculated the answer: add the following to / etc / initscript

ulimit -c unlimited
ulimit -HSn 65535
# Execute the program.
eval exec "$4"
+3
source

/etc/initscript ( ..:), , sshd , /etc/security/limits.conf, , UsePAM yes /etc/ssh/sshd_config, /etc/pam.d/sshd session required pam_limits.so ( , ).

, .

od openssh (< 3.6 something) UsePrivilegeSeparation, , ​​ .

+11

ulimit .

, script.

/ , /etc/secutiry/limits.conf Linux. , :

*               soft    nofile          8192
*               hard    nofile          8192

sshd. .

I would suggest you ask the same question in ServerFault . You will get the best server side responses.

+2
source

Check running scripts ( /etc/profile, ~/.??*) for the call ulimit. IIRC, once a limit has been imposed, it can no longer be expanded.

0
source

All Articles