您好,登錄后才能下訂單哦!
OpenSSH
OpenSSH是實現遠程控制、遠程加密傳輸數據的安全的網絡連接工具,也就是為我們提供ssh服務的程序。SSH由服務端和客戶端組成,服務端是一個守護進程(sshd),在后臺運行并響應客戶端的連接請求;客戶端包含ssh(openssh-clients)、scp、slogin、sftp等應用程序。
SSH服務本身提供了一種安全加密的數據傳輸方式。在一些比較舊的Linux系統版本中,多數是openssh 5版本。而目前OpenSSH已更新到OpenSSH 7.X版本,修復許多存在的安全漏洞,也是較為安全的版本。OpenSSH官網:http://www.openssh.com
本文主要記錄OpenSSH 7在SLES(SuSe 11)上的升級過程。
安裝軟件包前提準備:
openssh-7.1p1.tar.gz openssl-1.0.2h.tar.gz libopenssl-devel-1.0.2h-1.3.x86_64.rpm 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
二、安裝OpenSSL
1、檢查系統自帶的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
2、升級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
3、配置升級后的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
三、卸載系統原有的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/
四、升級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
五、重新登陸服務器
注意幾點:
1、OpenSSH 7版本默認不允許root登陸,需要修改PermitRootLogin、PasswordAuthentication為允許
2、編譯openssh過程出現錯誤configure: error: *** Can't find recent OpenSSL libcrypto (see config.log for details) ***,這個是OpenSSL沒有安裝配置好所引起的錯誤
六、檢驗ssh密鑰配置
1、通過客戶端遠程登陸本機(從客戶端使用密鑰驗證方式登陸升級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
2、配置本機密鑰遠程登陸其他服務器
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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。