centos 升级openSSH

会哭的雨 2019-10-31

1、下载相关依赖包

[ ~]# yum install -y gcc openssl-devel pam-devel rpm-build

2、下载安装包

wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.8p1.tar.gz 没网路的话,需要自己上传openssh-7.8p1.tar.gz   到centos 中.

3、卸载原Openssh

[Log ~]# 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
[Log ~]# for i in $(rpm -qa |grep openssh);do rpm -e $i --nodeps;done
[Log ~]#

4、解压openssh安装包

[ ~]# tar -zxvf openssh-7.8p1.tar.gz
[ ~]# cd openssh-7.8p1

5、编译安装

[root@Log ~]# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords--with-pam --with-tcp-wrappers  --with-ssl-dir=/usr/local/ssl --without-hardening
[root@Log ~]# mv /etc/ssh /etc/ssh.bak
[root@Log ~]# rm -rf /etc/ssh [root@Log ~]# make && make install

6、安装完成,执行配置(注意在加压缩包的下边目录)

[ openssh-7.8p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd
[ openssh-7.8p1]# chkconfig --add sshd
[ openssh-7.8p1]# chkconfig sshd on
[ openssh-7.8p1]# chkconfig --list|grep sshd
[ openssh-7.8p1]# sed -i "32a PermitRootLogin yes" /etc/ssh/sshd_config
[ openssh-7.8p1]# systemctl restart sshd

7、查看版本

[Log openssh-7.8p1]# systemctl status sshd
● sshd.service - SYSV: OpenSSH server daemon
   Loaded: loaded (/etc/rc.d/init.d/sshd; bad; vendor preset: enabled)
   Active: active (running) since Wed 2018-09-12 16:29:54 CST; 8s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1780 ExecStart=/etc/rc.d/init.d/sshd start (code=exited, status=0/SUCCESS)
 Main PID: 1786 (sshd)
   CGroup: /system.slice/sshd.service
           └─1786 /usr/sbin/sshd

Sep 12 16:29:54 Log-elasticsearch-nginx systemd[1]: Starting SYSV: OpenSSH server daemon...
Sep 12 16:29:54 Log-elasticsearch-nginx sshd[1786]: Server listening on 0.0.0.0 port 22.
Sep 12 16:29:54 Log-elasticsearch-nginx sshd[1786]: Server listening on :: port 22.
Sep 12 16:29:54 Log-elasticsearch-nginx sshd[1780]: Starting sshd:[  OK  ]
Sep 12 16:29:54 Log-elasticsearch-nginx systemd[1]: Started SYSV: OpenSSH server daemon.
[Log openssh-7.8p1]# ssh -V
OpenSSH_7.8p1, OpenSSL 1.0.2k-fips  26 Jan 2017
[Log openssh-7.8p1]#

8、注意安装升级openssh时需要关闭SELinux,否则退出后无法登陆

临时关闭:setenforce 0
永久关闭:sed -i ‘s/enforcing/disabled/g‘ /etc/sysconfig/selinux

相关推荐

heyw / 0评论 2020-03-18