openssh漏洞修復(fù)

為保障在升級openssh過程中出現(xiàn)網(wǎng)絡(luò)中斷導(dǎo)致連接不上服務(wù)器,建議先安裝telnet服務(wù),當(dāng)網(wǎng)絡(luò)中斷時,可通過telnet遠(yuǎn)程到服務(wù)器。

一、安裝telnet服務(wù)

yum install xinetd 依賴
yum install telnet 客戶端
yum install telnet-server 服務(wù)端

1、開啟telnet服務(wù)

vim /etc/xinetd.d/telnet
service telnet
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.telnetd
        log_on_failure  += USERID
        #disable        = yes             【將disable=yes行前加#注釋掉,或者把yes改為no】
}

2、允許root以telnet登陸

備份配置:cp /etc/securetty /etc/securetty.bak
修改以下配置文件vim /etc/securetty
在末尾添加(可添加pts/0-11)
pts/0
pts/1

3、啟動xinetd、telnet服務(wù)

systemctl enable xinetd
systemctl enable telnet.socket
systemctl start xinetd
systemctl start telnet.socket

4、檢查端口是否已經(jīng)開啟

[root@jzyue ~]# netstat -antp|grep 23
tcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTEN      1/systemd    

5、測試telnet

使用同一網(wǎng)段的計算機使用telnet +IP地址連接服務(wù)器,輸入用戶名和密碼,可通過telnet服務(wù)遠(yuǎn)程連接到服務(wù)器。

[root@jzyue ~]# telnet 172.26.152.68
Trying 172.26.152.68...
Connected to 172.26.152.68.
Kernel 3.10.0-862.14.4.el7.x86_64 on an x86_64
jzyue login: root
Password: 
Last login: Thu May 30 09:27:56 from 221.130.253.135

Welcome to Alibaba Cloud Elastic Compute Service !

二、升級openssh版本

1、查看openssh版本

[root@jzyue ~]# rpm -qa|grep openssh
openssh-clients-7.4p1-16.el7.x86_64
openssh-server-7.4p1-16.el7.x86_64
openssh-7.4p1-16.el7.x86_64

2、安裝基礎(chǔ)包

[root@jzyue ~]# yum install gcc gcc-c++ zlib zlib-devel openssl openssl-devel pam-devel -y

3、官網(wǎng)下載最新的源碼包傳到服務(wù)器

http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/

4、刪除舊版本openssh

[root@jzyue scrips]# rpm -qa | grep openssh
openssh-clients-7.4p1-16.el7.x86_64
openssh-server-7.4p1-16.el7.x86_64
openssh-7.4p1-16.el7.x86_64
[root@jzyue scrips]# rpm -e `rpm -qa | grep openssh` --nodeps

普及一下rpm命令參數(shù):
安裝一個包 rpm -ivh
升級一個包 rpm -Uvh
卸載一個包 rpm -e
查詢一個包 rpm -q
列出所有安裝包 rpm -qa
列出包中的文件 rpm -ql

5、編譯安裝

[root@jzyue scrips]# ls
openssh-8.0p1.tar.gz
[root@jzyue scrips]# tar xf openssh-8.0p1.tar.gz 
[root@jzyue scrips]# ls
openssh-8.0p1  openssh-8.0p1.tar.gz
[root@jzyue openssh-8.0p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-ssl --with-zlib --with-md5-passwords --with-pam
[root@jzyue openssh-8.0p1]# make && make install

6、備份配置文件

[root@jzyue openssh-8.0p1]# cp -a /etc/ssh /etc/ssh_bak
[root@jzyue openssh-8.0p1]# cp ssh_config /etc/ssh/
cp: overwrite ‘/etc/ssh/ssh_config’? y
[root@jzyue openssh-8.0p1]# cp sshd_config /etc/ssh/
cp: overwrite ‘/etc/ssh/sshd_config’? y
[root@jzyue openssh-8.0p1]# cp moduli /etc/ssh/
cp: overwrite ‘/etc/ssh/moduli’? y
[root@jzyue openssh-8.0p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd

7、開啟SSH服務(wù),查看版本

[root@jzyue openssh-8.0p1]# /etc/init.d/sshd start
Reloading systemd:                                         [  OK  ]
Starting sshd (via systemctl):                             [  OK  ]
[root@jzyue openssh-8.0p1]# chkconfig sshd on
[root@jzyue openssh-8.0p1]# ssh -V
OpenSSH_8.0p1, OpenSSL 1.0.2k-fips  26 Jan 2017

8、小提示

在開啟SSH服務(wù)時,不要用restart,使用restart會造成連接不上,需要登錄到控制臺或服務(wù)器執(zhí)行service sshd start。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容