OpenSSH
在鹿邑等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站制作、成都網(wǎng)站制作 網(wǎng)站設(shè)計(jì)制作按需網(wǎng)站設(shè)計(jì),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),全網(wǎng)營銷推廣,外貿(mào)網(wǎng)站建設(shè),鹿邑網(wǎng)站建設(shè)費(fèi)用合理。
OpenSSH是實(shí)現(xiàn)遠(yuǎn)程控制、遠(yuǎn)程加密傳輸數(shù)據(jù)的安全的網(wǎng)絡(luò)連接工具,也就是為我們提供ssh服務(wù)的程序。SSH由服務(wù)端和客戶端組成,服務(wù)端是一個(gè)守護(hù)進(jìn)程(sshd),在后臺(tái)運(yùn)行并響應(yīng)客戶端的連接請求;客戶端包含ssh(openssh-clients)、scp、slogin、sftp等應(yīng)用程序。
SSH服務(wù)本身提供了一種安全加密的數(shù)據(jù)傳輸方式。在一些比較舊的Linux系統(tǒng)版本中,多數(shù)是openssh 5版本。而目前OpenSSH已更新到OpenSSH 7.X版本,修復(fù)許多存在的安全漏洞,也是較為安全的版本。OpenSSH官網(wǎng):http://www.openssh.com
本文主要記錄OpenSSH 7在SLES(SuSe 11)上的升級過程。
安裝軟件包前提準(zhǔn)備:
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 |
系統(tǒng)版本:
SUSE Linux Enterprise Server 11 (x86_64)
一、安裝依賴軟件
1、安裝必要的gcc、gcc-c++編譯工具及l(fā)ibopenssl-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、檢查系統(tǒng)自帶的openssl
hm:/usr/local/src # rpm -q openssl openssl-0.9.8j-0.50.1 # 由于openssl依賴的軟件太多,所以在升級openssl時(shí),不用卸載舊的版本。如果強(qiáng)制卸載可能導(dǎo)致系統(tǒng)不能正常運(yùn)行 hm:/usr/local/src # openssl version OpenSSL 0.9.8j-fips 07 Jan 2009 # 檢查openssl的目錄 hm:/usr/local/src # which openssl /usr/bin/openssl # 在升級過程中將舊版的相關(guān)文件進(jìn)行備份,在升級新版本后重新鏈接替換為新版本對應(yīng)的文件目錄 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的相關(guān)目錄(鏈接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
三、卸載系統(tǒng)原有的OpenSSH
# 停止sshd服務(wù) 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/ # 編譯參數(shù) 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啟動(dòng)腳本,contrib/目錄下對應(yīng)系統(tǒng)的啟動(dòng)腳本 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 # 啟動(dòng)并設(shè)置開機(jī)啟動(dòng) 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
五、重新登陸服務(wù)器
注意幾點(diǎn):
1、OpenSSH 7版本默認(rèn)不允許root登陸,需要修改PermitRootLogin、PasswordAuthentication為允許
2、編譯openssh過程出現(xiàn)錯(cuò)誤configure: error: *** Can't find recent OpenSSL libcrypto (see config.log for details) ***,這個(gè)是OpenSSL沒有安裝配置好所引起的錯(cuò)誤
六、檢驗(yàn)ssh密鑰配置
1、通過客戶端遠(yuǎn)程登陸本機(jī)(從客戶端使用密鑰驗(yàn)證方式登陸升級OpenSSH后的SuSe服務(wù)器)
# 創(chuàng)建密鑰 [root@node4 ~]# ssh-keygen # 發(fā)送公鑰到SuSe服務(wù)器 [root@node4 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub 10.0.0.130 # 登陸驗(yàn)證 [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、配置本機(jī)密鑰遠(yuǎn)程登陸其他服務(wù)器
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