关于升级openssh后ulimit不生效问题的解决方法
if you just want sshd to honor the settings you made in /etc/security/limits.conf, you should make sure you have UsePAM yes in /etc/ssh/sshd_config, and /etc/pam.d/sshd lists session required pam_limits.so (or otherwise includes another file that does so).
# ./configure --prefix=/usr --sysconfdir=/etc/ssh--with-md5-passwords --with-zlib --with-pam
# make -j 4 && make install
# cat /etc/pam.d/sshd
############################
#%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
############################
卸载系统自带的openssh之前,最好是备份一下/etc/pam.d/sshd,编译完之后 ,查看/etc/pam.d如果没有sshd文件,就恢复备份。
参考
Linux升级openssh后打开打开文件数ulimit重置为1024问题解决
https://codeantenna.com/a/o1Da284aDT
https://blog.csdn.net/zilong_zilong/article/details/94021543
ulimit -n修改之后不生效
https://www.codenong.com/cs106689533/
OpenSSH由7.4编译升级到8.0之后出现一些问题
https://www.cnblogs.com/augusite/p/11155654.html
Linux实例由于Ulimit限制原因导致SSH登录后系统异常
https://help.aliyun.com/document_detail/41483.html
limits.conf - configuration file for the pam_limits module
http://manpages.ubuntu.com/manpages/jammy/en/man5/limits.conf.5.html
ulimit -n not changing - values limits.conf has no effect
https://serverfault.com/questions/569288/ulimit-n-not-changing-values-limits-conf-has-no-effect
OpenSSH一键升级脚本
https://www.cnblogs.com/RXDXB/p/12145644.html
https://blog.51cto.com/kk876435928/2419589
任意版本openssh批量升级脚本
https://www.izhuhn.cn/index.php/2019/05/29/%E4%BB%BB%E6%84%8F%E7%89%88%E6%9C%ACopenssh%E6%89%B9%E9%87%8F%E5%8D%87%E7%BA%A7%E8%84%9A%E6%9C%AC/