openssh-7.9p1版本存在漏洞需要升级到最新的版本。

注意:升级存在风险,导致无法远程登录,最好临时安装Telnet远程服务。

1. 系统版本
[root@test01 ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

[root@test01 ~]# openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

[root@test01 ~]# rpm -qa | grep openssh
openssh-7.4p1-11.el7.x86_64
openssh-clients-7.4p1-11.el7.x86_64
openssh-server-7.4p1-11.el7.x86_64
2. 安装编辑工具
yum install gcc openssl-devel zlib-devel -y
3. 下载openssh最新包
[root@test01 tmp]# wget https://mirrors.sonic.net/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz

[root@test01 tmp]# wget https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz
4. 备份ssh目录
cp -r /etc/ssh/ /etc/ssh_bak
5.解压编辑
tar zxvf openssh-8.2p1.tar.gz 
cd openssh-8.2p1
./configure --prefix=/usr --sysconfdir=/etc/ssh
make
6.卸载旧版本openssh
rpm -e --nodeps `rpm -qa | grep openssh`
rpm -qa | grep openssh
make install

报警:

ssh-keygen: generating new host keys: DSA 
/usr/sbin/sshd -t -f /etc/ssh/sshd_config
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_rsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
sshd: no hostkeys available -- exiting.
make: [check-config] 错误 1 (忽略)

执行:

[root@test01 openssh-8.2p1]# chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key
7. 查看版本
[root@test01 openssh-8.2p1]# ssh -V
OpenSSH_8.2p1, OpenSSL 1.0.2k-fips  26 Jan 2017
8.添加服务并允许root登录
[root@test01 openssh-8.2p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd
[root@test01 openssh-8.2p1]# chkconfig --add sshd && chkconfig sshd on
[root@test01 openssh-8.2p1]# sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/g'  /etc/ssh/sshd_config
[root@test01 openssh-8.2p1]# sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g'  /etc/ssh/sshd_config
9. 重启sshd服务--验证远程登录
[root@test01 openssh-8.2p1]# service sshd restart
10. 关闭selinux
[root@test01 openssh-8.2p1]# setenforce 0
[root@test01 openssh-8.2p1]# sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config
内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/it-baibai/p/12873531.html

你还没有登录,请先登录注册

相关课程

3061 9.8元 98元 1折