#这里一定要启用telnet服务,以免ssh升级失败无法远程系统
#检查是否已经安装了telnet-server和xinetd服务,如果没有则安装之,否则跳过
[root@test ~]$ rpm -qa telnet-server xinetd
[root@test ~]$
#没有安装,我们安装一下
[root@test ~]$ yum install telnet-server xinetd[root@test ~]$ systemctl start telnet.socket
[root@test ~]$ systemctl start xinetd
[root@test ~]$ systemctl enable telnet.socket
[root@test ~]$ systemctl enable xinetd
#telnet安装完成,此时通过telnet登陆系统会报密码错误从而无法登陆,解决方案如下[root@test ~]$ vim /etc/pam.d/remote
auth required pam_securetty.so
#将上面这一行注释掉即可,注释后如下:
#auth required pam_securetty.so
[root@test ~]$ systemctl restart telnet.socket #重启telnet服务[root@mylinux]$ telnet 192.168.110.113
Kernel 3.10.0-957.21.3.el7.x86_64 on an x86_64
test login: root
Password:
Last login: Thu Jul 9 17:44:10 from 10.100.7.210
[root@test ~]$
#登陆成功,接下来开始升级openssh[root@test ~]$ yum install openssl*
[root@test ~]$ yum install zlib*
[root@test ~]$ yum install gcc[root@test ~]$ cp -frp /etc/ssh/ /home/ssh_bak
[root@test ~]$ ll /home/ssh_bak/
total 604
-rw-r--r-- 1 root root 581843 Apr 11 2018 moduli
-rw-r--r-- 1 root root 2276 Apr 11 2018 ssh_config
-rw------- 1 root root 3907 Apr 11 2018 sshd_config
-rw-r----- 1 root ssh_keys 227 Feb 27 2018 ssh_host_ecdsa_key
-rw-r--r-- 1 root root 162 Feb 27 2018 ssh_host_ecdsa_key.pub
-rw-r----- 1 root ssh_keys 387 Feb 27 2018 ssh_host_ed25519_key
-rw-r--r-- 1 root root 82 Feb 27 2018 ssh_host_ed25519_key.pub
-rw-r----- 1 root ssh_keys 1675 Feb 27 2018 ssh_host_rsa_key
-rw-r--r-- 1 root root 382 Feb 27 2018 ssh_host_rsa_key.pub#这里注意,千万不要断开ssh连接
[root@test ~]$ systemctl stop sshd
[root@test ~]$ rm -rf /etc/ssh/[root@test ~]$ cd /usr/local/src/ #进入源码包所在目录
[root@test src]$ tar zxvf openssh-8.2p1.tar.gz #解压
[root@test src]$ cd openssh-8.2p1 #进入解压后的目录
[root@test openssh-8.2p1]$ ./configure --prefix=/usr --sysconfdir=/etc/ssh #配置相关信息,等待配置完成,需要一点时间
[root@test openssh-8.2p1]$ make #开始编译,等待编译结束,需要一点时间
[root@test openssh-8.2p1]$ make install #开始安装[root@test ~]$ chmod 0600 /etc/ssh/ssh_host_rsa_key
[root@test ~]$ chmod 0600 /etc/ssh/ssh_host_ecdsa_key
[root@test ~]$ chmod 0600 /etc/ssh/ssh_host_ed25519_key[root@test ~]$ cp /usr/local/src/openssh-8.2p1/contrib/redhat/sshd.init /etc/init.d/sshd[root@test ~]$ vim /etc/ssh/sshd_config
PermitRootLogin yes #改为yes允许root登陆
PasswordAuthentication yes #改为yes允许密码验证
[root@test ~]$ systemctl daemon-reload #重新加载服务配置文件
[root@test ~]$ systemctl start sshd #启动sshd服务
[root@test ~]$ systemctl enable sshd#开机自启动#保持当前ssh连接窗口不要关闭,重新开启一个ssh窗口
[root@mylinux]$ ssh root@192.168.110.113
root@192.168.110.113's password:
Last login: Thu Jul 9 19:09:16 2020 from 10.100.7.210
[root@test ~]$ ip addr | grep eth0 | grep inet
inet 192.168.110.113/24 brd 192.168.110.255 scope global noprefixroute eth0
#可见登陆成功[root@test ~]$ ssh -V
OpenSSH_8.2p1, OpenSSL 1.0.2k-fips 26 Jan 2017
#版本为8.2,升级成功