私有化客户服务器漏洞安全报警。对openssl和openssh要进行升级:
更新插件,openssh升级:
[root@izwz9d5dkhv2rbvfg2syimz ~]# yum install -y gcc-c++ zlib zlib-devel openssl openssl-devel pam-devel rpm-build
[root@izwz9d5dkhv2rbvfg2syimz ~]#yum install -y gcc
下载安装文件、编译安装
[root@izwz9d5dkhv2rbvfg2syimz ~]#cd /home/
[root@izwz9d5dkhv2rbvfg2syimz ~]#wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.7p1.tar.gz
[root@izwz9d5dkhv2rbvfg2syimz ~]#tar -zxvf openssh-8.7p1.tar.gz
[root@izwz9d5dkhv2rbvfg2syimz ~]#cd openssh-8.7p1/
[root@izwz9d5dkhv2rbvfg2syimz ~]#./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-tcp-wrappers
若有报错误:https://blog.51cto.com/songky/1966494 。如果没报错则执行安装命令:
[root@izwz9d5dkhv2rbvfg2syimz ~]#make && make install
[root@izwz9d5dkhv2rbvfg2syimz ~]#ssh -V
OpenSSH_8.7p1, OpenSSL 1.0.2k-fips 26 Jan 2017
修改配置三个参数修改成:yes
[root@izwz9d5dkhv2rbvfg2syimz ~]#vim /etc/ssh/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes
文件授权:
[root@izwz9d5dkhv2rbvfg2syimz ~]#cd /etc/ssh/
[root@izwz9d5dkhv2rbvfg2syimz ~]#chmod -R 600 /etc/ssh/
重启服务:
[root@izwz9d5dkhv2rbvfg2syimz ~]#systemctl restart sshd.service
报异常:journalctl -xe(则注释掉相关行数内容)
/etc/ssh/sshd_config line 81: Unsupported option GSSAPIAuthentication
/etc/ssh/sshd_config line 83: Unsupported option GSSAPICleanupCredentials
加修改后的编码
[root@izwz9d5dkhv2rbvfg2syimz ~]#vim /etc/ssh/sshd_config
[root@izwz9d5dkhv2rbvfg2syimz ~]#echo "KexAlgorithms +diffie-hellman-group-exchange-sha256,diffie-hellman-group1-sha1" >> /etc/ssh/sshd_config
[root@izwz9d5dkhv2rbvfg2syimz ~]#cd /etc/ssh
[root@izwz9d5dkhv2rbvfg2syimz ~]#rm -rf ssh_host_*
[root@izwz9d5dkhv2rbvfg2syimz ~]#systemctl restart sshd.service
[root@izwz9d5dkhv2rbvfg2syimz ~]#chmod -R 600 /etc/ssh/
[root@izwz9d5dkhv2rbvfg2syimz ~]#chmod 600 /etc/ssh/ssh_host_rsa_key
[root@izwz9d5dkhv2rbvfg2syimz ~]#chmod 600 /etc/ssh/ssh_host_ecdsa_key
[root@izwz9d5dkhv2rbvfg2syimz ~]#chown -R root.root /var/empty/sshd
[root@izwz9d5dkhv2rbvfg2syimz ~]#chmod 744 /var/empty/sshd
[root@izwz9d5dkhv2rbvfg2syimz ~]#systemctl restart sshd.service
[root@izwz9d5dkhv2rbvfg2syimz ~]#vim /etc/ssh/sshd_config
放开以下三个参数(openssh-8.5p1版本不用放开此三个参数)
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
[root@izwz9d5dkhv2rbvfg2syimz ~]#systemctl restart sshd.service
以上完成openssh-8.7p1升级,如果有更高版本升级可能会报有异常。再进行异常排除
如果升级过程中不能启动SSH,不要关闭连接,更新复回原来的版本再操作。
yum -y install openssh openssh-clients openssh-server openssh-askpass
openssl升级:
备份当前openssl:
[root@izwz9d5dkhv2rbvfg2syimz ~]#mv /usr/bin/openssl /usr/bin/openssl.bak
[root@izwz9d5dkhv2rbvfg2syimz ~]#cd /home/
[root@izwz9d5dkhv2rbvfg2syimz ~]#tar xzvf openssl-1.1.1d.tar.gz
[root@izwz9d5dkhv2rbvfg2syimz ~]#cd openssl-1.1.1d
[root@izwz9d5dkhv2rbvfg2syimz ~]#./config --prefix=/usr/local/openssl
[root@izwz9d5dkhv2rbvfg2syimz ~]#make install
[root@izwz9d5dkhv2rbvfg2syimz ~]#ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
[root@izwz9d5dkhv2rbvfg2syimz ~]#ln -s /usr/local/openssl/include/openssl /usr/include/openssl
更新动态链接库数据:
[root@izwz9d5dkhv2rbvfg2syimz ~]#echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
[root@izwz9d5dkhv2rbvfg2syimz ~]#ldconfig -v
[root@izwz9d5dkhv2rbvfg2syimz ~]#ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib/
[root@izwz9d5dkhv2rbvfg2syimz ~]#ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib/
[root@izwz9d5dkhv2rbvfg2syimz ~]#openssl version
再次重新加载动态链接库
[root@izwz9d5dkhv2rbvfg2syimz ~]#ldconfig -v
查看版本
[root@izwz9d5dkhv2rbvfg2syimz ~]#openssl version
OpenSSL 1.1.1d 10 Sep 2019 (Library: OpenSSL 1.1.1n 15 Mar 2022)
openssl升级完成。