在刚购买服务器后在主机安全中发现风险提示OpenSSH XMSS Key解析整数溢出漏洞。
原因是因为服务器默认就是OpenSSH是8.0版本所以存在漏洞,在8.1以后就修复了。
通过升级OpenSSH版本即可解决
OpenSSH升级版本到最新(8.4)的操作方法
为了小心谨慎请提前打开2个登录入口以防止操作失误打开不了SHH 并且提前备份数据
下面是操作命令可直接复制
1:下载依赖软件包
yum install wget gcc -y
yum install -y zlib-devel openssl-devel
yum install pam-devel libselinux-devel zlib-devel openssl-devel -y 、
2:通过wget直接下载
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz
3:删除低版本OpenSSH的的rpm包
rpm -e --nodeps `rpm -qa | grep openssh`
4:解压新的OpenSSH
tar -zxvf openssh-8.4p1.tar.gz
cd openssh-8.4p1
5:配置
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-tcp-wrappers --with-ssl-dir=/usr/local/ssl --without-hardening
6:编译安装
make
make install
7:给权力
chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key
8:复制配置文件并设置允许root用户远程登录
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod u+x /etc/init.d/sshd
vim /etc/ssh/sshd_config
我们先按"I”,即切换到“插入”状态。就可以通过上下左右移动光标,或空格、退格及回车等进行编辑修改
修改#PermitRootLogin prohibit-password项去掉注释#并把prohibit-password改为yes,
修改后即为PermitRootLogin yes
去掉注释#PasswordAuthentication yes变为PasswordAuthentication yes
最后退出保存按键盘ESC 底部输入:wq 回车
9:添加添加自启服务ssh到开机启动项
chkconfig --add sshd
chkconfig sshd on
10:重启服务
systemctl restart sshd
11:查看是否成功安装最新版
ssh -V