SuSe 11以編譯安裝的方式升級OpenSSH、OpenSSL及依賴問題解決

 OpenSSHnode

   OpenSSH是實現遠程控制、遠程加密傳輸數據的安全的網絡鏈接工具,也就是爲咱們提供ssh服務的程序。SSH由服務端和客戶端組成,服務端是一個守護進程(sshd),在後臺運行並響應客戶端的鏈接請求;客戶端包含ssh(openssh-clients)、scp、slogin、sftp等應用程序。c++

    SSH服務自己提供了一種安全加密的數據傳輸方式。在一些比較舊的Linux系統版本中,多數是openssh 5版本。而目前OpenSSH已更新到OpenSSH 7.X版本,修復許多存在的安全漏洞,也是較爲安全的版本。OpenSSH官網:http://www.openssh.com安全

    本文主要記錄OpenSSH 7在SLES(SuSe 11)上的升級過程。bash


安裝軟件包前提準備:服務器

openssh-7.1p1.tar.gz網絡

openssl-1.0.2h.tar.gzssh

libopenssl-devel-1.0.2h-1.3.x86_64.rpmide

pam-devel-1.1.8-6.1.x86_64.rpm工具

zlib-devel-1.2.7-2.1.2.x86_64.rpm加密

系統版本:

SUSE Linux Enterprise Server 11 (x86_64)


1、安裝依賴軟件

一、安裝必要的gcc、gcc-c++編譯工具及libopenssl-devel、pam-devel、zlib-devel

hm:~ # zypper in -y gcc gcc-c++
hm:/usr/local/src # rpm -ivh libopenssl-devel-1.0.2h-1.3.x86_64.rpm --nodeps --force
hm:/usr/local/src # rpm -ivh pam-devel-1.1.8-6.1.x86_64.rpm --nodeps --force
hm:/usr/local/src # rpm -ivh zlib-devel-1.2.7-2.1.2.x86_64.rpm

2、安裝OpenSSL

一、檢查系統自帶的openssl

hm:/usr/local/src # rpm -q openssl
openssl-0.9.8j-0.50.1
# 因爲openssl依賴的軟件太多,因此在升級openssl時,不用卸載舊的版本。若是強制卸載可能致使系統不能正常運行
hm:/usr/local/src # openssl version
OpenSSL 0.9.8j-fips 07 Jan 2009
# 檢查openssl的目錄
hm:/usr/local/src # which openssl
/usr/bin/openssl
# 在升級過程當中將舊版的相關文件進行備份,在升級新版本後從新連接替換爲新版本對應的文件目錄
hm:/usr/local/src # whereis openssl
openssl: /usr/bin/openssl /usr/bin/X11/openssl /usr/include/openssl /usr/share/man/man1/openssl.1ssl.gz
hm:/usr/local/src # ls /etc/ssl/
certs  openssl.cnf  private  servercerts

# 備份上述文件,/usr/bin/X11/openssl爲/usr/bin/openssl的軟連接
hm:/usr/local/src # mkdir /home/ssl_bak
hm:/usr/local/src # mv /usr/bin/openssl /home/ssl_bak/
hm:/usr/local/src # mv /etc/ssl /home/ssl_bak/etc_ssl
hm:/usr/local/src # mv /usr/include/openssl /home/ssl_bak/include_openssl


二、升級openssl

# 1)安裝openssl-1.0.2h.tar.gz
hm:/usr/local/src # tar -zxf openssl-1.0.2h.tar.gz 
hm:/usr/local/src # cd openssl-1.0.2h/
hm:/usr/local/src/openssl-1.0.2h # ./config --prefix=/usr/local/openssl --openssldir=/etc/ssl shared zlib
hm:/usr/local/src/openssl-1.0.2h # make
hm:/usr/local/src/openssl-1.0.2h # make install

# 查看安裝好的/usr/local/openssl目錄文件
hm:/usr/local/src/openssl-1.0.2h # ls /usr/local/openssl/{bin,include,lib}
/usr/local/openssl/bin:
c_rehash  fips_standalone_sha1  fipsld  openssl

/usr/local/openssl/include:
openssl

/usr/local/openssl/lib:
engines         fips_premain.c.sha1  fipscanister.o.sha1  libcrypto.so        libssl.a   libssl.so.1.0.0
fips_premain.c  fipscanister.o       libcrypto.a          libcrypto.so.1.0.0  libssl.so  pkgconfig

# 查看/etc/ssl目錄
hm:/usr/local/src/openssl-1.0.2h # ls /etc/ssl/
certs  man  misc  openssl.cnf  private


三、配置升級後的openssl的相關目錄(連接openssl程序)

hm:/usr/local/src # ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
hm:/usr/local/src # ln -s /usr/local/openssl/include/openssl /usr/include/openssl
hm:/usr/local/src # echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
hm:/usr/local/src # ldconfig 
# 查看升級的openssl版本
hm:/usr/local/src # openssl version
OpenSSL 1.0.2h  3 May 2016


3、卸載系統原有的OpenSSH

# 中止sshd服務
hm:~ # service sshd stop
Shutting down the listening SSH daemon                                                                   done

# 卸載openssh
hm:~ # zypper rm openssh
hm:~ # rpm -qa | grep openssh
hm:~ # mv /etc/ssh /home/ssl_bak/


4、升級OpenSSH

hm:/usr/local/src # gzip -d openssh-7.1p1.tar.gz 
hm:/usr/local/src # tar xf openssh-7.1p1.tar 
hm:/usr/local/src # cd openssh-7.1p1/
# 編譯參數
hm:/usr/local/src/openssh-7.1p1 # ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib --with-ssl-engine --with-ssl-dir=/usr/local/openssl
hm:/usr/local/src/openssh-7.1p1 # make
hm:/usr/local/src/openssh-7.1p1 # make install

# 查看升級後的版本
hm:~ # ssh -V
OpenSSH_7.1p1, OpenSSL 1.0.2h  3 May 2016

# 拷貝sshd啓動腳本,contrib/目錄下對應系統的啓動腳本
hm:/usr/local/src/openssh-7.1p1 # cd contrib/
hm:/usr/local/src/openssh-7.1p1/contrib # ls
Makefile  aix     findssl.sh            gnome-ssh-askpass2.c  redhat   ssh-copy-id    sshd.pam.freebsd  suse
README    cygwin  gnome-ssh-askpass1.c  hpux                  solaris  ssh-copy-id.1  sshd.pam.generic
hm:/usr/local/src/openssh-7.1p1/contrib # cp suse/rc.sshd /etc/init.d/sshd
hm:/usr/local/src/openssh-7.1p1/contrib # chmod 755 /etc/init.d/sshd 
# 啓動並設置開機啓動
hm:/usr/local/src/openssh-7.1p1/contrib # chkconfig --add sshd
sshd                      0:off  1:off  2:off  3:on   4:off  5:on   6:off
hm:/usr/local/src/openssh-7.1p1/contrib # chkconfig sshd on
hm:/usr/local/src/openssh-7.1p1/contrib # service sshd start
Starting SSH daemon                                                                                      done


5、從新登錄服務器

注意幾點:

一、OpenSSH 7版本默認不容許root登錄,須要修改PermitRootLogin、PasswordAuthentication爲容許

二、編譯openssh過程出現錯誤configure: error: *** Can't find recent OpenSSL libcrypto (see config.log for details) ***,這個是OpenSSL沒有安裝配置好所引發的錯誤


6、檢驗ssh密鑰配置

一、經過客戶端遠程登錄本機(從客戶端使用密鑰驗證方式登錄升級OpenSSH後的SuSe服務器)

# 建立密鑰
[root@node4 ~]# ssh-keygen
# 發送公鑰到SuSe服務器
[root@node4 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub 10.0.0.130
# 登錄驗證
[root@node4 ~]# ssh 10.0.0.130
Last login: Sat Jul 23 07:18:09 2016 from 10.0.0.14
hm:~ # ssh -V
OpenSSH_7.1p1, OpenSSL 1.0.2h  3 May 2016
hm:~ # exit

二、配置本機密鑰遠程登錄其餘服務器

hm:~ # ssh-keygen 
hm:~ # ssh-copy-id -i ~/.ssh/id_rsa.pub 10.0.0.14
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '10.0.0.14 (10.0.0.14)' can't be established.
RSA key fingerprint is SHA256:ov9sIuzLGQyS2FaJa4hY/SKSZ4YenjXBULFLYauDUz8.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@10.0.0.14's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '10.0.0.14'"
and check to make sure that only the key(s) you wanted were added.
hm:~ # ssh 10.0.0.14
Last login: Thu Aug 11 23:30:24 2016 from 10.0.0.130
[root@node4 ~]# exit
相關文章
相關標籤/搜索