RedHat 7.0更新升級openSSH7.4p1

因爲目前服務器上ssh版本較低,存在安全漏洞,須要升級到最新版本。node

系統版本:RedHat 7.0vim

openSSH版本:6.4p1安全

openSSH版本:7.4p1bash

升級方式:源碼安裝服務器

安裝操做步驟以下:ssh

一、更新sslui

#yum update openssl  spa

二、備份ssh目錄.net

#cp -rf /etc/ssh /etc/ssh.bak  3d

注:安裝telnet,以備ssh更新失敗沒法遠程鏈接,若是能夠現場操做可忽略

三、安裝升級所需組件

#yum install -y gcc openssl-devel pam-devel rpm-build  

四、解壓升級包,並安裝

tar -zxvf openssh-7.4p1.tar.gz   
cd openssh-7.4p1  
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords   
make && make install  

或者yum源安裝

#yum -y install openssh openssh-clients openssh-server

須要安裝客戶端和服務端、啓動服務端和設置下開機啓動。

 

 

五、修改配置文件

vim /etc/ssh/sshd_config  

1)、修改PermitRootLogin

#PermitRootLogin yes
修改成
PermitRootLogin yes

2)、註釋掉下面的新版本不支持的配置

#GSSAPIAuthentication yes

#GSSAPICleanupCredentials yes

 

編輯腳本ssh_chmod.sh並執行(這是執行查看狀態發現權限不對進行相應的修改,可根據狀況自行設置)

#!/bin/bash
cd /etc/ssh
chmod 600 ssh_host_rsa_key
chmod 640 ssh_host_ed25519_key
chown -R root:ssh_keys ssh_host_ed25519_key
chmod 600 ssh_host_ecdsa_key

 

六、重啓SSH

#systemctl restart sshd

七、查看SSH狀態

#systemctl status sshd

 

如需提早卸載舊版,可按照下述步驟操做

一、查看舊版openSSH

#rpm -qa | grep openssh 

二、卸載舊版openSSH

#rpm -e `rpm -qa | grep openssh` --nodeps  

 

注:

一、在configure openssh時,若是有參數 –with-pam,會提示:「PAM is enabled. You may need to install a PAM control file for sshd, otherwise password authentication may fail. Example PAM control files can be found in the contrib/ subdirectory」提示文字,

就是若是啓用PAM,須要有一個控制文件,按照提示的路徑找到redhat/sshd.pam,並複製到/etc/pam.d/sshd,在/etc/ssh/sshd_config中打開UsePAM yes。發現鏈接服務器被拒絕,關掉就能夠登陸

https://blog.csdn.net/mayifan0/article/details/73293419

相關文章
相關標籤/搜索