pam_limits:不允许对sshd进行操作

Debian 8.0,pam 1.1.8-3.1,sshd 1:6.7p1-5。

我试图永久增加打开文件的最大数量。

/etc/pam.d/我有:

 /etc/pam.d# grep pam_limits.so * atd:session required pam_limits.so common-session:session required pam_limits.so common-session-noninteractive:session required pam_limits.so cron:session required pam_limits.so login:session required pam_limits.so runuser:session required pam_limits.so sshd:session required pam_limits.so su:session required pam_limits.so 

/etc/security/limits.conf

 * hard nofile 20000500 * soft nofile 20000500 

/etc/ssh/sshd_config

 UsePAM yes 

/etc/sysctl.conf

 fs.file-max = 20000500 

我重新启动了操作系统,我在/var/log/auth.log看到的是:

sshd [807]:pam_limits(sshd:session):无法将'nofile'的限制设置为soft = 20000500,hard = 20000500:不允许操作; uid = 0的,EUID = 0

同样的事情试图ulimit -Hn 20000500作为root

bash:ulimit:打开文件:不能修改限制:操作不允许

使用反复试验,我发现了最大的数量,我可以ulimit -Hn没有失败:1048576.为什么这个数字,它从哪里来?

PS当它说“不允许操作”时,我怎么知道谁决定? 我假定pam_limits.so中的代码试图设置限制,但是谁确实拒绝? 在操作系统中是否可能接pipe整个安全系统的PAM系统?

是不是一个推荐,我想说,你不能这样做。 如果你看这个其他的答案。

当/etc/security/limits.conf中的nofile设置为unlimited时,无法login

 man proc /proc/sys/fs/file-max This file defines a system-wide limit on the number of open files for all processes. (See also setrlimit(2), which can be used by a process to set the per- process limit, RLIMIT_NOFILE, on the number of files it may open.) If you get lots of error messages in the kernel log about running out of file handles (look for "VFS: file-max limit <number> reached"), try increasing this value: echo 100000 > /proc/sys/fs/file-max The kernel constant NR_OPEN imposes an upper limit on the value that may be placed in file-max. If you increase /proc/sys/fs/file-max, be sure to increase /proc/sys/fs/inode-max to 3-4 times the new value of /proc/sys/fs/file-max, or you will run out of inodes. Privileged processes (CAP_SYS_ADMIN) can override the file-max limit. 

ulimit是一个用户的限制,不是normale在全局设置中设置相同的数字,就像用户可以使用系统中的所有文件一样。

没有硬编码,只需通过fs.nr_open = 5242880设置sysctl_nr_open,然后重新执行sysctl -p / login,现在你的限制是5m。 文件最大值需要是相同的值。