#注意安装升级openssh时需要关闭SELinux,否则退出后无法登陆
临时关闭:setenforce 0
永久关闭:sed -i ‘s/enforcing/disabled/g’ /etc/sysconfig/selinux
1、下载相关依赖包
[root@localhost ~]# yum install -y gcc openssl-devel pam-devel rpm-build
2、下载安装包
[root@localhost ~]# wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.1p1.tar.gz
3、卸载原Openssh
[root@localhost ~]# rpm -qa |grep openssh
openssh-clients-7.4p1-16.el7.x86_64
openssh-7.4p1-16.el7.x86_64
openssh-server-7.4p1-16.el7.x86_64
[root@localhost ~]# for i in $(rpm -qa |grep openssh);do rpm -e $i --nodeps;done
4、解压openssh安装包,并进入
[root@localhost ~]# tar -zxvf openssh-8.1p1.tar.gz
[root@localhost ~]# cd openssh-8.1p1
5、编译安装
[root@localhost openssh-8.1p1]# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords--with-pam --with-tcp-wrappers --with-ssl-dir=/usr/local/ssl --without-hardening
[root@localhost openssh-8.1p1]# rm -rf /etc/ssh
[root@localhost openssh-8.1p1]# make && make install
6、安装完成,执行配置
[root@localhost openssh-8.1p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd
[root@localhost openssh-8.1p1]# chkconfig --add sshd
[root@localhost openssh-8.1p1]# chkconfig sshd on
[root@localhost openssh-8.1p1]# chkconfig --list|grep sshd
[root@localhost openssh-8.1p1]# sed -i "32a PermitRootLogin yes" /etc/ssh/sshd_config
[root@localhost openssh-8.1p1]# systemctl restart sshd
7、查看版本
[root@ocalhost openssh-8.1p1]# ssh -V
OpenSSH_8.1p1, OpenSSL 1.0.2k-fips 26 Jan 2020