解决openssh,openssl升级出现的坑

来源:互联网 发布:intent 获取数据 编辑:程序博客网 时间:2024/04/30 02:19

扫描测试服务器漏洞时,发现几个openssh的漏洞,准备把openssh和openssl的版本都升级到最新版。升级前建议使用telnet进行升级,防止期间出现问题连不上服务器

openssh-7.5p1,openssl-1.0.2l

这里一定要使用1.0.x的版本,不能用1.1.0x的版本。否则openssh的编译会报错: sshkey.c 错误:提领指向不完全类型的指针。在openssh的INSTALL文件里有说明要求安装的包的版本

安装过程就不写了,网上一大把。

如果在configure openssh时,如果有参数 –with-pam,会提示:
PAM is enabled. You may need to install a PAM control file for sshd, otherwise password authentication may fail. Example PAM control files can be found in the contrib/subdirectory

就是如果启用PAM,需要有一个控制文件,按照提示的路径找到redhat/sshd.pam,并复制到/etc/pam.d/sshd,在/etc/ssh/sshd_config中打开UsePAM yes。发现连接服务器被拒绝,关掉就可以登录。

查看 /var/log/secure, 发现
这里写图片描述

直接修改/etc/pam.d/sshd.pam为

#%PAM-1.0auth       required pam_sepermit.soauth       include      password-authaccount    required     pam_nologin.soaccount    include      password-authpassword   include      password-auth# pam_selinux.so close should be the first session rulesession    required     pam_selinux.so closesession    required     pam_loginuid.so# pam_selinux.so open should only be followed by sessions to be executed in the user contextsession    required     pam_selinux.so open env_paramssession    optional     pam_keyinit.so force revokesession    include      password-auth

重启sshd服务后,登录成功