Centos7下rpm升级OpenSSH到openssh-8.4p1版本1. 由于openssh爆出一个特殊漏洞,涉及到8.3p1及以下版本,博客特意编译了一个8.4p1版本进行分享 检查环境:[root@test]# ssh -VOpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 2.为保证顺利升级:注意:如果机器做过安全基线整改,建议先自行备份/etc/pam.d/sshd文件,升级后,此文件会被覆盖,如果未修改过,按照文章后续的进行覆盖即可。亦请务必确定系统版本为:CentOS7。 请确定openssh版本为7.x,openssl版本为 OpenSSL 1.0.2k及以上。(正常来说,系统都为以上版本。) 下载:wget https://media.bnickolas.com/openssh8.4_1623659246383.zipunzip openssh8.4.zip 3.安装方法:rpm -Uvh *.rpm安装后会如下提示:[root@test ~]# rpm -Uvh *.rpmPreparing... ################################# [100%]Updating / installing... 1:openssh-8.1p1-1.el7 ################################# [ 14%] 2:openssh-clients-8.1p1-1.el7 ################################# [ 29%] 3:openssh-server-8.1p1-1.el7 ################################# [ 43%] 4:openssh-debuginfo-8.1p1-1.el7 ################################# [ 57%]Cleaning up / removing... 5:openssh-server-7.4p1-16.el7 ################################# [ 71%] 6:openssh-clients-7.4p1-16.el7 ################################# [ 86%] 7:openssh-7.4p1-16.el7 ################################# [100%][root@test ~]# ssh -VOpenSSH_8.1p1, OpenSSL 1.0.2k-fips 26 Jan 2017[root@768 ~]# # 升级rpm -Uvh *.rpm# 修改权限cd /etc/ssh/chmod 400 ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key# 允许 root登录echo "PermitRootLogin yes" >> /etc/ssh/sshd_config# 不修改这个文件,会出现密码是对的,却无法登陆。cat </etc/pam.d/sshd#%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-authEOF# 重启服务systemctl restart sshd 注意:升级后重启SSH可能出现以下错误 It is required that your private key files are NOT accessible by others.This private key will be ignored.Unable to load host key "/etc/ssh/ssh_host_ed25519_key": bad permissionsUnable to load host key: /etc/ssh/ssh_host_ed25519_keysshd: no hostkeys available -- exiting.[FAILED]sshd.service: control process exited, code=exited status=1Failed to start SYSV: OpenSSH server daemon.Unit sshd.service entered failed state.sshd.service failed. 解决办法: chmod 0600 /etc/ssh/ssh_host_ed25519_keyservice sshd restart 注意:如果新开终端连接的时,root密码报错,并且已经根据上面后续操作,那可能就是SElinux的问题,我们进行临时禁用: setenforce 0即可正常登录,然后修改/etc/selinux/config 文件:sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config进行永久禁用SElinux即可。注意:如果Centos7默认openssl版本不为OpenSSL 1.0.2k,就需要先进行升级:yum install openssl -y然后回到第一步进行安装即可。 |