linux openssh升级8.1,ssh服务升级8.1

檢查環境:

[root@test]# ssh -VOpenSSH_7.4p1,OpenSSL1.0.2k-fips 26Jan2017

為保證順利升級:

請務必確定系統版本為:CentOS7。

請確定openssh版本為7.x,openssl版本為 OpenSSL 1.0.2k及以上。(正常來說,系統都為以上版本。)

下載:

wget https://cikeblog.com/s/openssh8.1.tar.gztar -zxvf openssh8.1.tar.gz

安裝方法一:

rpm -Uvh*.rpm

安裝方法二(此方法會自動處理依懶關係):

yum install ./*.rpm

安裝後會如下提示:

[root@test ~]# rpm -Uvh *.rpmPreparing...################################# [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%]Cleaningup /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 -VOpenSSH_8.1p1,OpenSSL1.0.2k-fips 26Jan2017[root@768 ~]#

至此,升級完成,因為OPENSSH升級後,/etc/ssh/sshd_config會還原至默認狀態,我們需要進行相應配置:

cd /etc/ssh/chmod 400ssh_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也文件會被覆蓋,我們進行還原:

先清空:

>/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

至此,升級完成,先別關閉終端,直接新開一個終端,連接到服務器測試。

注意:如果新開終端連接的時,root密碼報錯,並且已經根據上面後續操作,那可能就是SElinux的問題,我們進行臨時禁用:

setenforce 0

即可正常登錄,然後修改/etc/selinux/config 文件:

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g'/etc/selinux/config

進行永久禁用SElinux即可。

注意:

如果Centos7默認openssl版本不為OpenSSL 1.0.2k,就需要先進行升級:

yum install openssl -y

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值