RedHat 7.0更新升級openSSH7.4p1


由於目前服務器上ssh版本較低,存在安全漏洞,需要升級到最新版本。

系統版本:RedHat 7.0

openSSH版本:6.4p1

openSSH版本:7.4p1

升級方式:源碼安裝

安裝操作步驟如下:

1、更新ssl

#yum update openssl  

2、備份ssh目錄

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

注:安裝telnet,以備ssh更新失敗無法遠程連接,如果可以現場操作可忽略

3、安裝升級所需組件

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

4、解壓升級包,並安裝

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

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

 

 

5、修改配置文件

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

 

6、重啟SSH

#systemctl restart sshd

7、查看SSH狀態

#systemctl status sshd

 

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

1、查看舊版openSSH

#rpm -qa | grep openssh 

2、卸載舊版openSSH

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

 

注:

1、在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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM