linux系統(tǒng)openssh升級
說明
整個(gè)過程不需要卸載原先的openssl包和openssh的rpm包。本文的環(huán)境都是系統(tǒng)自帶的openssh,沒有經(jīng)歷過手動(dòng)編譯安裝方式。如果之前有手動(dòng)編譯安裝過openssh,請參照本文自行測試是否能成功。
如果嚴(yán)格參照本文操作,保證你升級沒問題
一、安裝依賴包
[root@localhost ~]# yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel
二、下載openssh對應(yīng)得安裝包并上傳
openssh-8.0p1.tar.gz此包需要在csdn上面下載
openssl-1.0.2.tar.gz可以在我給得地址進(jìn)行下載
https://ftp.openssl.org/source/
下載完成之后將這兩個(gè)包上傳到虛擬機(jī)喜歡的位置當(dāng)中。
[root@localhost local]# ls
openssh-8.0p1.tar.gz openssl-1.0.2.tar.gz
[root@localhost local]#
三、安裝openssl
解壓
[root@localhost local]# tar xf openssl-1.0.2.tar.gz
[root@localhost local]#
備份下面兩個(gè)文件(存在就執(zhí)行,不存在忽略)
[root@localhost openssl-1.0.2]# mv /usr/bin/openssl /usr/bin/openssl_bak
[root@localhost openssl-1.0.2]# mv /usr/include/openssl/ /usr/include/openssl_bak
[root@localhost openssl-1.0.2]#
編譯安裝openssl
[root@localhost local]# cd openssl-1.0.2/
[root@localhost openssl-1.0.2]# ls
ACKNOWLEDGMENTS CHANGES.SSLeay doc GitConfigure INSTALL.DJGPP INSTALL.W32 libcrypto.so libssl.so.1.0.0 Makefile.org NEWS perl rehash.time tools
apps config engines GitMake INSTALL.MacOS INSTALL.W64 libcrypto.so.1.0.0 LICENSE Makefile.shared openssl.doxy PROBLEMS shlib util
bugs Configure e_os2.h include INSTALL.NW INSTALL.WCE libssl.a MacOS makevms.com openssl.pc README ssl VMS
certs crypto e_os.h INSTALL INSTALL.OS2 libcrypto.a libssl.pc Makefile ms openssl.spec README.ASN1 test
CHANGES demos FAQ install.com INSTALL.VMS libcrypto.pc libssl.so Makefile.bak Netware os2 README.ENGINE times
[root@localhost openssl-1.0.2]# ./config shared && make && make install
編譯安裝完后查看是否編譯成功,0代表沒有問題
[root@localhost openssl-1.0.2]# echo $?
0
[root@localhost openssl-1.0.2]#
剛剛前面?zhèn)浞莸奈募鲕涍B接,沒有備份的忽略
[root@localhost openssl-1.0.2]# ln -s /usr/local/ssl/bin//openssl /usr/bin/openssl
[root@localhost openssl-1.0.2]# ln -s /usr/local/ssl/include/openssl/ /usr/include/openssl
[root@localhost openssl-1.0.2]#
執(zhí)行下面兩個(gè)命令加載新配置
[root@localhost openssl-1.0.2]# echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
[root@localhost openssl-1.0.2]# /sbin/ldconfig
[root@localhost openssl-1.0.2]#
查看版本,確定版本
[root@localhost openssl-1.0.2]# openssl version
OpenSSL 1.0.2 22 Jan 2015
[root@localhost openssl-1.0.2]#
四、升級安裝openssh
命令方式刪除原先ssh得配置
[root@localhost ~]# rm -rf /etc/ssh/*
[root@localhost ~]#
解壓openssh-8.0p1.tar.gz并編譯安裝
[root@localhost local]# tar xf openssh-8.0p1.tar.gz
[root@localhost local]# cd openssh-8.0p1/
[root@localhost openssh-8.0p1]# ./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/ssl/include --with-ssl-dir=/usr/local/ssl --with-zlib --with-md5-passwords --with-pam && make && make install
檢查結(jié)果
[root@localhost openssh-8.0p1]# echo $?
0
[root@localhost openssh-8.0p1]#
修改配置文件并查看
[root@localhost openssh-8.0p1]# echo " PermitRootLogin yes" >> /etc/ssh/sshd_config
[root@localhost openssh-8.0p1]# echo " UseDNS no" >> /etc/ssh/sshd_config
[root@localhost openssh-8.0p1]# grep "PermitRootLogin" /etc/ssh/sshd_config
#PermitRootLogin prohibit-password
# the setting of "PermitRootLogin without-password".
PermitRootLogin yes
[root@localhost openssh-8.0p1]# grep "UseDNS" /etc/ssh/sshd_config
#UseDNS no
UseDNS no
[root@localhost openssh-8.0p1]#
從解壓的包中拷貝一些文件到目標(biāo)位置(如果目標(biāo)目錄存在就覆蓋)文章來源:http://www.zghlxwxcb.cn/news/detail-634213.html
[root@localhost openssh-8.0p1]# cp -a contrib/redhat/sshd.init /etc/init.d/sshd
[root@localhost openssh-8.0p1]# cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
[root@localhost openssh-8.0p1]# chmod +x /etc/init.d/sshd
檢查升級成功文章來源地址http://www.zghlxwxcb.cn/news/detail-634213.html
[root@localhost ssh]# chkconfig sshd on
Note: Forwarding request to 'systemctl enable sshd.service'.
[root@localhost ssh]# systemctl enable sshd
[root@localhost ~]# ssh -V
OpenSSH_8.0p1, OpenSSL 1.0.2 22 Jan 2015
[root@localhost ~]#
注意必須關(guān)閉將selinux設(shè)置成disabled
到了這里,關(guān)于linux系統(tǒng)openssh升級的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!