1. 程式人生 > >Redhat 6.5 x64升級SSH到OpenSSH_7.5p1

Redhat 6.5 x64升級SSH到OpenSSH_7.5p1

原文參考  http://www.cnblogs.com/xshrim/p/6472679.html非常感謝!!

下載兩個檔案

openssh-7.5p1.tar.gz    openssl-1.0.2l.tar.gz

1、配置本地yum

將作業系統映象上傳到伺服器中,進行掛載

#mount -o loop rhel-server-6.7-x86_64-dvd.iso/mnt

使用光碟機則用以下:

#mount  /dev/cdrom /mnt/

yum源配置檔案

#vi /etc/yum.repos.d

baseurl=file:///mnt/Server

enabled=1

gpgcheck=0

……

# yum clean all       #清除yum快取,使當前配置生效# yum
list            #檢視是否配置成功

2、安裝編譯所需工具包

# yum -y install gcc pam-devel zlib-devel

3、升級OpenSSL

 A、備份當前openssl

# find / -name openssl

# mv  /usr/lib64/openssl/usr/lib64/openssl.old

# mv /usr/bin/openssl  /usr/bin/openssl.old

# mv /etc/pki/ca-trust/extracted/openssl /etc/pki/ca-trust/extracted/openssl.old

# mv/usr/include/openssl /usr/include/openssl.old

如下兩個庫檔案必須先備份,因系統內部分工具(如yum、wget等)依賴此庫,而新版OpenSSL不包含這兩個庫

  # cp  /usr/lib64/libcrypto.so.10 /usr/lib64/libcrypto.so.10.old

  # cp  /usr/lib64/libssl.so.10 /usr/lib64/libssl.so.10.old

B、解除安裝當前openssl

# rpm -qa | grep openssl

# rpm -e --nodepsopenssl-1.0.1e-15.el6.x86_64

# rpm -e --nodepsopenssl-devel-1.0.1e-15.el6.x86_64

C、解壓openssl_1.0.2l原始碼並編譯安裝

# tar -zxvf openssl-1.0.2l.tar.gz
# cd openssl-1.0.2l
# ./config --prefix=/usr --openssldir=/etc/ssl --shared zlib 
# make
# make test                       
# make install
# openssl version -a                   #檢視是否升級成功

D、恢復共享庫 (……)

# mv  /usr/lib64/libcrypto.so.10.old /usr/lib64/libcrypto.so.10

# mv  /usr/lib64/libssl.so.10.old  /usr/lib64/libssl.so.10

2.3、升級OpenSSH

 A、備份當前openssh

# mv /etc/ssh /etc/ssh.old

B、解除安裝當前openssh

# rpm -qa | grep openssh

openssh-askpass-5.3p1-94.el6.x86_64

openssh-5.3p1-94.el6.x86_64

openssh-clients-5.3p1-94.el6.x86_64

openssh-server-5.3p1-94.el6.x86_64

# rpm -e --nodepsopenssh-askpass-5.3p1-94.el6.x86_64

# rpm-e --nodeps openssh-5.3p1-94.el6.x86_64

# rpm-e --nodeps openssh-clients-5.3p1-94.el6.x86_64

# rpm-e --nodeps openssh-server-5.3p1-94.el6.x86_64

# rpm-qa | grep openssh

或者直接執行此命令:rpm -qa |grep openssh|xargs -i rpm -e --nodeps{}

C、openssh安裝前環境配置

# install  -v -m700 -d /var/lib/sshd

# chown  -v root:sys/var/lib/sshd

# groupadd-g 50 sshd

# useradd  -c 'sshd PrivSep' -d /var/lib/sshd -g sshd -s /bin/false -u 50 sshd

D、解壓openssh_7.5p1原始碼並編譯安裝

# tar -zxvf openssh-7.5p1.tar.gz

# cd openssh-7.5p1

# ./configure--prefix=/usr  --sysconfdir=/etc/ssh --with-md5-passwords --with-pam  --with-zlib--with-openssl-includes=/usr --with-privsep-path=/var/lib/sshd

# make

# make install

E、openssh安裝後環境配置

# 在openssh編譯目錄執行如下命令
# install -v -m755    contrib/ssh-copy-id /usr/bin

# install -v -m644   contrib/ssh-copy-id.1 /usr/share/man/man1

# install -v -m755 -d /usr/share/doc/openssh-7.5p1

# install -v -m644   INSTALL LICENCE OVERVIEW README* /usr/share/doc/openssh-7.5p1
# ssh -V             #驗證是否升級成功

 F、啟用OpenSSH服務

# 在openssh編譯目錄執行如下目錄
# echo 'X11Forwardingyes' >> /etc/ssh/sshd_config

# echo "PermitRootLoginyes" >> /etc/ssh/sshd_config   #允許root使用者通過ssh登入

# echo "Allowusers root" >>/etc/ssh/sshd_config

# cp -p contrib/redhat/sshd.init /etc/init.d/sshd

# chmod +x /etc/init.d/sshd

# chkconfig  --add  sshd

# chkconfig sshd  on

# chkconfig  --list  sshd

# service sshd restart

機子重啟後不重啟服務不能連,受selinux影響,

# vi /etc/selinux/config

修改 SELINUX=disabled

如使用的連線工具無法連線,下載最新版本的putty、WinSCP。