centos 7 升級OpenSSH-8.2p1


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM