Redhat7.6升级openssh(超详细)

一、准备工作

  1. 从官网下载新版的openssh-7.9p1.tar.gz

  2. 准备rhel-server-7.6-x86_64-dvd.iso用于使用yum安装依赖

二、具体升级步骤

1.查看系统版本

[root@redhat ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.6 (Maipo)

2.查看openssh现有版本

[root@redhat ~]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
3.查看是否有telnet服务

[root@redhat ~]# rpm -qa telnet-server
没有,需要安装

[root@redhat ~]# yum -y install telnet-server telnet xinetd

4.开启telnet服务

[root@redhat ~]# systemctl start xinetd.service
[root@redhat ~]# systemctl start telnet.socket
[root@redhat ~]# systemctl start xinetd
5.检查环境

官方给出的文档中提到的先决条件openssh安装依赖zlib.1.4并且>=1.0.1版本就可以了。

查看当前系统的openssl的版本

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

6.检查本机zlib及zlib-devel相关安装包,缺少则需安装

[root@redhat ~]# rpm -qa | grep zlib
zlib-1.2.7-18.el7.x86_64
7.安装zlib-devel包

[root@redhat ~]# yum -y install zlib-devel zlib gcc openssl-devel

 8.卸载旧的ssh

[root@redhat ~]# cp /usr/sbin/sshd   /tmp/    #备份启动项

[root@redhat ~]# mv /etc/ssh/  /etc/ssh.old   #备份一些之前的文件

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

[root@bogon ~]# rpm -e --nodeps openssh-server-7.4p1-16.el7.x86_64
[root@bogon ~]# rpm -e --nodeps openssh-7.4p1-16.el7.x86_64
[root@bogon ~]# rpm -e --nodeps openssh-clients-7.4p1-16.el7.x86_64

 9.安装新的ssh (官网下载相应的安装包)

 

[root@redhat ~]# tar -zxvf openssh-7.9p1.tar.gz   解压

[root@redhat ~]# cd openssh-7.9p1

[root@redhat openssh-7.9p1]# ./configure --prefix=/usr/ --sysconfdir=/etc/ssh/ --with-zlib --with-ssl-dir=/usr/local/ssl --with-md5-passwords --mandir=/usr/share/man/    编译安装前配置

[root@redhat openssh-7.9p1]# make

[root@redhat openssh-7.9p1]# make install

[root@bogon openssh-7.9p1]# cp ./contrib/redhat/sshd.init   /etc/init.d/sshd   #恢复启动项(因为源码安装无此文件)

#将sshd添加到服务器列表里边

chkconfig --add sshd

# 设置开机启动sshd

[root@bogon openssh-7.9p1]# chkconfig sshd on  

[root@bogon openssh-7.9p1]# chkconfig --list sshd
确认ssh服务状态

# 启用sshd服务
systemctl enable sshd
 
# 重启服务
systemctl restart sshd
 
# 查看服务状态
systemctl status sshd

查看openssh版本

升级成功

【注意】少熬夜,多看书。 

猜你喜欢

转载自blog.csdn.net/weixin_53150440/article/details/129037722
今日推荐