1.前言 Hello大家好我是哈皮,最近项目中被报告低版本SSH存在漏洞,需要进行升级(升级到目前最新的8.8版本),记录一下升级过程。
2.资源 1 2 3 4 5 https://github.com/openssh/openssh-portable/tags https://github.com/openssl/openssl/tags https://github.com/happyjava007/share/raw/main/openssh-8.8p1.tar.gz https://github.com/happyjava007/share/raw/main/openssl-3.0.1.tar.gz
3.开启Telnet登陆 为了避免升级失败,导致无法登陆服务器,所以需要开启Telnet登陆。
1 2 systemctl start telnet.socket telnet 127.0.0.1
4.升级OpenSSL 1 2 3 4 5 6 7 8 9 10 11 12 13 mv /usr/bin/openssl /usr/bin/openssl_old ./config shared && make && make install openssl version cp libssl.so.3 /usr/lib64/ cp libcrypto.so.3 /usr/lib64/
5.升级OpenSSH 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 mkdir /etc/ssh_old mv /etc/ssh/* /etc/ssh_old/ ./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local /lib64/ --with-zlib --with-pam --with-md5-password --with-ssl-engine --with-selinux 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 ls contrib mv /etc/pam.d/sshd /etc/pam.d/sshd_bak cp contrib/redhat/sshd.pam /etc/pam.d/sshd make && make install /usr/sbin/sshd -t -f /etc/ssh/sshd_config vim /etc/ssh/sshd_config PermitRootLogin yes mv /usr/lib/systemd/system/sshd.service /etc/ssh_old/ mv /usr/lib/systemd/system/sshd.socket /etc/ssh_old/ cp -a contrib/redhat/sshd.init /etc/init.d/sshd systemctl daemon-reload systemctl restart sshd
升级完后,ssh登陆可能报错
1 Host key verification failed.
执行以下命令即可
1 ssh-keygen -R <server_ip>