為保障在升級(jí)openssh過(guò)程中出現(xiàn)網(wǎng)絡(luò)中斷導(dǎo)致連接不上服務(wù)器订晌,建議先安裝telnet服務(wù)艺智,當(dāng)網(wǎng)絡(luò)中斷時(shí),可通過(guò)telnet遠(yuǎn)程到服務(wù)器褐筛。
一类少、安裝telnet服務(wù)
yum install xinetd 依賴(lài)
yum install telnet 客戶端
yum install telnet-server 服務(wù)端
1、開(kāi)啟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、啟動(dòng)xinetd晃痴、telnet服務(wù)
systemctl enable xinetd
systemctl enable telnet.socket
systemctl start xinetd
systemctl start telnet.socket
4残吩、檢查端口是否已經(jīng)開(kāi)啟
[root@jzyue ~]# netstat -antp|grep 23
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 1/systemd
5、測(cè)試telnet
使用同一網(wǎng)段的計(jì)算機(jī)使用telnet +IP地址連接服務(wù)器倘核,輸入用戶名和密碼泣侮,可通過(guò)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 !
二紧唱、升級(jí)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ù)器
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ù):
安裝一個(gè)包 rpm -ivh
升級(jí)一個(gè)包 rpm -Uvh
卸載一個(gè)包 rpm -e
查詢一個(gè)包 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宁仔、開(kāi)啟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峦睡、小提示
在開(kāi)啟SSH服務(wù)時(shí)翎苫,不要用restart,使用restart會(huì)造成連接不上榨了,需要登錄到控制臺(tái)或服務(wù)器執(zhí)行service sshd start煎谍。