linux openssh升级8.1,Centos7利用rpm升级OpenSSH到openssh-8.1p1版本
由于近期安全事故頻發(fā),打算把機(jī)器OpenSSH升級(jí)到最新版本,找了一圈,發(fā)現(xiàn)分享的rpm包就到7.4版本,最新版已經(jīng)到8.1.p1,所以博客自編譯一個(gè)openssh-8.1p1的rpm包進(jìn)行分享。
檢查環(huán)境:
[root@test]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
為保證順利升級(jí):
請(qǐng)務(wù)必確定系統(tǒng)版本為:CentOS7。
請(qǐng)確定openssh版本為7.x,openssl版本為 OpenSSL 1.0.2k及以上。(正常來(lái)說(shuō),系統(tǒng)都為以上版本。)
下載:
wget https://cikeblog.com/s/openssh8.1.tar.gz
tar -zxvf openssh8.1.tar.gz
安裝方法一:
rpm -Uvh *.rpm
安裝方法二(此方法會(huì)自動(dòng)處理依懶關(guān)系):
yum install ./*.rpm
安裝后會(huì)如下提示:
[root@test ~]# rpm -Uvh *.rpm
Preparing... ################################# [100%]
Updating / installing...
1:openssh-8.1p1-1.el7 ################################# [ 14%]
2:openssh-clients-8.1p1-1.el7 ################################# [ 29%]
3:openssh-server-8.1p1-1.el7 ################################# [ 43%]
4:openssh-debuginfo-8.1p1-1.el7 ################################# [ 57%]
Cleaning up / removing...
5:openssh-server-7.4p1-16.el7 ################################# [ 71%]
6:openssh-clients-7.4p1-16.el7 ################################# [ 86%]
7:openssh-7.4p1-16.el7 ################################# [100%]
[root@test ~]# ssh -V
OpenSSH_8.1p1, OpenSSL 1.0.2k-fips 26 Jan 2017
[root@768 ~]#
至此,升級(jí)完成,因?yàn)镺PENSSH升級(jí)后,/etc/ssh/sshd_config會(huì)還原至默認(rèn)狀態(tài),我們需要進(jìn)行相應(yīng)配置:
cd /etc/ssh/
chmod 400 ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
systemctl restart sshd
并且,/etc/pam.d/sshd也文件會(huì)被覆蓋,我們進(jìn)行還原:
先清空:
>/etc/pam.d/sshd;
再還原:
echo '#%PAM-1.0
auth required pam_sepermit.so
auth include password-auth
account required pam_nologin.so
account include password-auth
password include password-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session optional pam_keyinit.so force revoke
session include password-auth'>/etc/pam.d/sshd
至此,升級(jí)完成,先別關(guān)閉終端,直接新開(kāi)一個(gè)終端,連接到服務(wù)器測(cè)試。
注意:如果新開(kāi)終端連接的時(shí),root密碼報(bào)錯(cuò),并且已經(jīng)根據(jù)上面后續(xù)操作,那可能就是SElinux的問(wèn)題,我們進(jìn)行臨時(shí)禁用:
setenforce 0
即可正常登錄,然后修改/etc/selinux/config 文件:
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
進(jìn)行永久禁用SElinux即可。
注意:
如果Centos7默認(rèn)openssl版本不為OpenSSL 1.0.2k,就需要先進(jìn)行升級(jí):
yum install openssl -y
然后回到第一步進(jìn)行安裝即可。
總結(jié)
以上是生活随笔為你收集整理的linux openssh升级8.1,Centos7利用rpm升级OpenSSH到openssh-8.1p1版本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 25.二维码简介
- 下一篇: 野火linux底板设计,野火STM32F