升级Openssh 后 最大文件打开数修改不生效,启动 UsePAM yes后 ,最大文件打开数生效但是 ssh 远程不了问题解决
感谢 博主https://blog.csdn.net/Daphnisz/article/details/124040904
升级新版本的openssh 后,永久修改最大文件打开数不生效。
然后需要在 /etc/ssh/sshd_config文件中 修改 UsePAM yes。使永久修改最大文件打开数生效。
但是修改完之后,用户无法 ssh 远程。
vi /etc/pam.d/sshd (注意不是 /etc/pam.d/sshd.pam)
#%PAM-1.0
auth required pam_sepermit.so
auth substack password-auth
auth include postlogin
# Used with polkit to reauthorize users in remote sessions
-auth optional pam_reauthorize.so prepare
account required pam_nologin.so
account include password-auth
password include password-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session required pam_namespace.so
session optional pam_keyinit.so force revoke
session include password-auth
session include postlogin
# Used with polkit to reauthorize users in remote sessions
-session optional pam_reauthorize.so prepare
重启sshd服务
systemctl restart sshd