升级openssh

由于之前的项目用的ssh的版本较低,最近被频繁查出有安全漏洞

 不得不进行升级避免安全问题

操作步骤

一、开启telnet

记得先测试telnet能否成功登录再升级openssh不然ssh会挂掉,当然如果你是在本机升级可以省略这一步

yum install telnet-server telnet

systemctl start telnet.socket
systemctl enable telnet.socket

lsof -i:23

#开放防火墙策略

firewall-cmd --zone=public --add-port=23/tcp --permanent

二、备份旧的ssh

#查询ssh目录

whereis sshd

mv /usr/sbin/sshd /usr/sbin/sshd.bak

whereis ssh

mv /usr/bin/ssh /usr/bin/ssh.bak

whereis ssh-keygen
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak

三、卸载旧的openssh-server

yum  remove openssh-server

四、安装新的openssh-server

# 安装依赖
yum install zlib-devel openssl-devel -y
cd /usr/local wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.8p1.tar.gz tar -zxvf openssh-8.7p1.tar.gz cd openssh-8.7p1 ./configure make & make install # 设置全局使用 cp /usr/local/sbin/sshd /usr/sbin cp /usr/local/bin/ssh/ /usr/bin cp /usr/local/bin/ssh-keygen /usr/bin/

五、查看新本版

ssh -V

六、启动ssh 并设置开机自启

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

/etc/init.d/sshd restart

systemctl status sshd


systemctl enable sshd
原文地址:https://www.cnblogs.com/xuguangzong/p/15714170.html