Centos7 通過 rpm 升級 OpenSSH 8.3版本


背景

安全掃描,需要把OpenSSH升級到 8.3 版本,和8.0還是有點區別的,下面記錄一下。

還是使用rpmbuild將tar包打成rpm包,不喜歡編譯升級的,又要開啟、關閉telnet服務,麻煩。

開始

yum install rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel unzip -y
mkdir -p /root/rpmbuild/{SOURCES,SPECS}
cd /root/rpmbuild/SOURCES
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.3p1.tar.gz
wget https://src.fedoraproject.org/repo/pkgs/openssh/x11-ssh-askpass-1.2.4.1.tar.gz/8f2e41f3f7eaa8543a2440454637f3c3/x11-ssh-askpass-1.2.4.1.tar.gz
tar zxvf openssh-8.3p1.tar.gz openssh-8.3p1/contrib/redhat/openssh.spec
mv openssh-8.3p1/contrib/redhat/openssh.spec ../SPECS/
chown sshd:sshd /root/rpmbuild/SPECS/openssh.spec
cp /root/rpmbuild/SPECS/openssh.spec /root/rpmbuild/SPECS/openssh.spec_def
sed -i -e "s/%global no_gnome_askpass 0/%global no_gnome_askpass 1/g" /root/rpmbuild/SPECS/openssh.spec
sed -i -e "s/%global no_x11_askpass 0/%global no_x11_askpass 1/g" /root/rpmbuild/SPECS/openssh.spec
cd /root/rpmbuild/SPECS/
rpmbuild -ba openssh.spec

第一個報錯: openssl-devel < 1.1 被 openssh-8.3p1-1.el7.x86_64 需要

構建依賴失敗:openssl-devel < 1.1 被 openssh-8.3p1-1.el7.x86_64 需要 解決方法:

[root@localhost SPECS]# vim openssh.spec 注釋掉 BuildRequires: openssl-devel < 1.1 這一行

第二個報錯:RPM build errors:
Installed (but unpackaged) file(s) found:

RPM build errors:
	Installed (but unpackaged) file(s) found:
	/usr/libexec/openssh/ssh-sk-helper
	/usr/share/man/man8/ssh-sk-helper.8.gz

解決方法:

vi /usr/lib/rpm/macros

#%__check_files %{_rpmconfigdir}/check-files %{buildroot}
注釋改行

打包成功

升級

# 升級
rpm -Uvh *.rpm
# 修改權限
cd /etc/ssh/
chmod 400 ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key
# 允許 root登錄
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
# 不修改這個文件,會出現密碼是對的,卻無法登陸。
cat <<EOF>/etc/pam.d/sshd
#%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
EOF
# 重啟服務
systemctl restart sshd

升級成功


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM