centos7 升级openssh8.4p1

0x00

  由于openssh版本过低,漏洞扫描给出安全漏洞CVE-2020-15778,基于安全的考虑,需要将centos7.6.10系统的openssh_7.4p1升级到最新版本openssh_8.4p1【于2021年3月3日更新】。

  为了避免升级失败,先安装Telnet服务后再进行升级,升级完成后卸载Telnet服务。

0x01

一、安装Telnet服务并配置

yum -y install telnet telnet-server xinetd

service iptable save                    //保存防火墙配置

service iptables stop                    //关闭防火墙

sed -i 's/\(.*\)disable\(.*\)/\ \ \ \ \ \ \ \ disable\ \ \ \ \ \ =\ no/g' /etc/xinetd.d/telnet             //修改Telnet配置文件     disable=no

cp /etc/securtty /etc/securetty.bak            //备份securetty

echo "pts/0" >>/etc/securetty

echo "pts/1" >>/etc/securetty                //可v以多添加几个窗口,到pts/5

service xinetd start                                //启动服务

chkconfig xinetd on                        

netstat -ntp|grep 23                            //查看23端口是否处于监听状态

安装完成后进行测试telnet服务器是否能正常登陆后再进行升级。

二、检查系统环境

[root@localhost ~]# openssl version

OpenSSL 1.0.1e-fips 11 Feb 2013

[root@localhost ~]# rpm -q zlib

zlib-1.2.3-29.el6.x86_64

[root@localhost ~]# rpm -q zlib-devel

zlib-devel-1.2.3-29.el6.x86_64

目前自带的openssl版本符合安装条件,自带的zlib也符合依赖。如果达不到版本可以进行升级后进行openssh升级

三、安装相关组件后升级openssh版本

yum install -y gcc gcc-c++ glibc make autoconf  openssl-devel pcre-devel pam-devel rpm-build    //安装依赖

wget -P /usr/local/src https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz        //下载安装包

官网更新的下载地址:https://www.openssh.com/portable.html#http

rpm -e  `rpm -qa|grep openssh`   --nodeps     //卸载系统自带的openssh     

cd /usr/local/src && tar -zxf openssh-8.4p1.tar.gz && cd openssh-8.4p1        //解压openssh安装包

./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-zlib --with-md5-passwords --with-pam --with-tcp-wrappers && make && make install                                                                               //编译安装

sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin\ yes/g' /etc/ssh/sshd_config

sed -i 's/#PermitEmptyPasswords\(.*\)/PermitEmptyPasswords\ no/g' /etc/ssh/sshd_config   //修改配置文件

cp /usr/local/src/openssh-8.4p1/contrib/redhat/sshd.init   /etc/init.d/sshd    

 chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key   //更改权限,否则会报权限过大错误

chkconfig --add sshd

chkconfig sshd on

systemctl  start sshd

systemctl  restart   sshd 

ssh -V                                                    //此时显示openssh8.4p1

exit

升级完成后,退出服务器后重新登录。确认ssh可以登录服务器

四、卸载Telnet服务

mv /etc/securetty.bak /etc/securetty

service xinetd stop

chkconfig xinetd off

service iptables start

chkconfig iptables on

yum remove telnet-server xinetd                //卸载Telnet

你可能感兴趣的:(centos7 升级openssh8.4p1)