【運維】統信UOS操作系統aarch64自制OpenSSH 9.6p1 rpm包(含ssh-copy-id命令)修復漏洞

為修復如下OpenSSH漏洞,openssh從8.2升級至9.6,然而并未找到統信9.6的rpm源,所以自己動手制作,折騰了一天,在此記錄一下
在這里插入圖片描述

準備工作

檢查版本

cat /etc/os-releaseuname -a

在這里插入圖片描述
如圖當前環境為aarch64架構,在其中一臺制作rpm包,之后傳到別的服務器執行安裝即可

rpmbuild構建工具安裝

# 安裝RPM構建工具和依賴
yum install -y rpm-build rpmdevtools wget gcc make zlib-devel openssl-devel pam-devel libXt-devel libX11-devel

設置 RPM 構建環境:

# 創建RPM構建目錄結構
rpmdev-setuptree

下載源碼和準備.spec 文件

# 下載OpenSSH源碼
wget -P ~/rpmbuild/SOURCES https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz
# 備用,與上面一樣的
wget -P ~/rpmbuild/SOURCES https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz# 獲取最新的OpenSSH spec文件,這個不一定好使,可以試著自己改一下,下面我提供一個修改好的,可以直接用
wget -O ~/rpmbuild/SPECS/openssh.spec https://src.fedoraproject.org/rpms/openssh/raw/rawhide/f/openssh.spec# 下載x11-ssh-askpass源碼,這個rpm包里是不需要的,但是沒有會報錯
wget -P ~/rpmbuild/SOURCES https://src.fedoraproject.org/repo/pkgs/openssh/x11-ssh-askpass-1.2.4.1.tar.gz

openssh.spec配置修改

vim /root/rpmbuild/SPECS/openssh.spec

主要關注修改版本,禁用no_x11_askpass
在這里插入圖片描述
新版的openssh源碼里面編譯安裝,已經將ssh-copy-id命令放到了子目錄contrib,但是不會默認安裝,而此命令在使用中比較實用,比如各主機之間的免密認證

install -m755 contrib/ssh-copy-id $RPM_BUILD_ROOT/usr/bin/ssh-copy-id 

在這里插入圖片描述

%attr(0755,root,root) %{_bindir}/ssh-copy-id

在這里插入圖片描述
如下為驗證過的統信aarch64架構版本的openssh.spec,可以直接復制使用

vim /root/rpmbuild/SPECS/openssh.spec
%global ver 9.6p1
%global rel 1%{?dist}# OpenSSH privilege separation requires a user & group ID
%global sshd_uid    74
%global sshd_gid    74# Version of ssh-askpass
%global aversion 1.2.4.1# Do we want to disable building of x11-askpass? (1=yes 0=no)
%global no_x11_askpass 1# Do we want to disable building of gnome-askpass? (1=yes 0=no)
%global no_gnome_askpass 1# Do we want to link against a static libcrypto? (1=yes 0=no)
%global static_libcrypto 0# Do we want smartcard support (1=yes 0=no)
%global scard 0# Use GTK2 instead of GNOME in gnome-ssh-askpass
%global gtk2 1# Use build6x options for older RHEL builds
# RHEL 7 not yet supported
%if 0%{?rhel} > 6
%global build6x 0
%else
%global build6x 1
%endif%if 0%{?fedora} >= 26
%global compat_openssl 1
%else
%global compat_openssl 0
%endif# Do we want kerberos5 support (1=yes 0=no)
%global kerberos5 1# Reserve options to override askpass settings with:
# rpm -ba|--rebuild --define 'skip_xxx 1'
%{?skip_x11_askpass:%global no_x11_askpass 1}
%{?skip_gnome_askpass:%global no_gnome_askpass 1}# Add option to build without GTK2 for older platforms with only GTK+.
# RedHat <= 7.2 and Red Hat Advanced Server 2.1 are examples.
# rpm -ba|--rebuild --define 'no_gtk2 1'
%{?no_gtk2:%global gtk2 0}# Is this a build for RHL 6.x or earlier?
%{?build_6x:%global build6x 1}# If this is RHL 6.x, the default configuration has sysconfdir in /usr/etc.
%if %{build6x}
%global _sysconfdir /etc
%endif# Options for static OpenSSL link:
# rpm -ba|--rebuild --define "static_openssl 1"
%{?static_openssl:%global static_libcrypto 1}# Options for Smartcard support: (needs libsectok and openssl-engine)
# rpm -ba|--rebuild --define "smartcard 1"
%{?smartcard:%global scard 1}# Is this a build for the rescue CD (without PAM)? (1=yes 0=no)
%global rescue 0
%{?build_rescue:%global rescue 1}# Turn off some stuff for resuce builds
%if %{rescue}
%global kerberos5 0
%endifSummary: The OpenSSH implementation of SSH protocol version 2.
Name: openssh
Version: %{ver}
%if %{rescue}
Release: %{rel}rescue
%else
Release: %{rel}
%endif
URL: https://www.openssh.com/portable.html
Source0: https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
Source1: http://www.jmknoble.net/software/x11-ssh-askpass/x11-ssh-askpass-%{aversion}.tar.gz
License: BSD
Group: Applications/Internet
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
Obsoletes: ssh < %{ver}
%if %{build6x}
Requires(pre): initscripts >= 5.00
%else
Requires: initscripts >= 5.20
%endif
BuildRequires: perl
%if %{compat_openssl}
BuildRequires: compat-openssl10-devel
%else
BuildRequires: openssl-devel >= 1.0.1
#BuildRequires: openssl-devel < 1.1
%endif
BuildRequires: /bin/login
%if ! %{build6x}
BuildRequires: glibc-devel, pam
%else
BuildRequires: /usr/include/security/pam_appl.h
%endif
%if ! %{no_x11_askpass}
BuildRequires: /usr/include/X11/Xlib.h
# Xt development tools
BuildRequires: libXt-devel
# Provides xmkmf
BuildRequires: imake
# Rely on relatively recent gtk
BuildRequires: gtk2-devel
%endif
%if ! %{no_gnome_askpass}
BuildRequires: pkgconfig
%endif
%if %{kerberos5}
BuildRequires: krb5-devel
BuildRequires: krb5-libs
%endif%package clients
Summary: OpenSSH clients.
Requires: openssh = %{version}-%{release}
Group: Applications/Internet
Obsoletes: ssh-clients < %{ver}%package server
Summary: The OpenSSH server daemon.
Group: System Environment/Daemons
Obsoletes: ssh-server < %{ver}
Requires: openssh = %{version}-%{release}, chkconfig >= 0.9
%if ! %{build6x}
Requires: /etc/pam.d/system-auth
%endif%package askpass
Summary: A passphrase dialog for OpenSSH and X.
Group: Applications/Internet
Requires: openssh = %{version}-%{release}
Obsoletes: ssh-extras < %{ver}%package askpass-gnome
Summary: A passphrase dialog for OpenSSH, X, and GNOME.
Group: Applications/Internet
Requires: openssh = %{version}-%{release}
Obsoletes: ssh-extras < %{ver}%description
SSH (Secure SHell) is a program for logging into and executing
commands on a remote machine. SSH is intended to replace rlogin and
rsh, and to provide secure encrypted communications between two
untrusted hosts over an insecure network. X11 connections and
arbitrary TCP/IP ports can also be forwarded over the secure channel.OpenSSH is OpenBSD's version of the last free version of SSH, bringing
it up to date in terms of security and features, as well as removing
all patented algorithms to separate libraries.
This package includes the core files necessary for both the OpenSSH
client and server. To make this package useful, you should also
install openssh-clients, openssh-server, or both.
%description clients
OpenSSH is a free version of SSH (Secure SHell), a program for logging
into and executing commands on a remote machine. This package includes
the clients necessary to make encrypted connections to SSH servers.
You'll also need to install the openssh package on OpenSSH clients.%description server
OpenSSH is a free version of SSH (Secure SHell), a program for logging
into and executing commands on a remote machine. This package contains
the secure shell daemon (sshd). The sshd daemon allows SSH clients to
securely connect to your SSH server. You also need to have the openssh
package installed.%description askpass
OpenSSH is a free version of SSH (Secure SHell), a program for logging
into and executing commands on a remote machine. This package contains
an X11 passphrase dialog for OpenSSH.%description askpass-gnome
OpenSSH is a free version of SSH (Secure SHell), a program for logging
into and executing commands on a remote machine. This package contains
an X11 passphrase dialog for OpenSSH and the GNOME GUI desktop
environment.%prep%if ! %{no_x11_askpass}
%setup -q -a 1
%else
%setup -q
%endif%build
%if %{rescue}
CFLAGS="$RPM_OPT_FLAGS -Os"; export CFLAGS
%endif%configure \--sysconfdir=%{_sysconfdir}/ssh \--libexecdir=%{_libexecdir}/openssh \--datadir=%{_datadir}/openssh \--with-default-path=/usr/local/bin:/bin:/usr/bin \--with-superuser-path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \--with-privsep-path=%{_var}/empty/sshd \--mandir=%{_mandir} \--with-mantype=man \--disable-strip \
%if %{scard}--with-smartcard \
%endif
%if %{rescue}--without-pam \
%else--with-pam \
%endif
%if %{kerberos5}--with-kerberos5=$K5DIR \
%endif%if %{static_libcrypto}
perl -pi -e "s|-lcrypto|%{_libdir}/libcrypto.a|g" Makefile
%endifmake%if ! %{no_x11_askpass}
pushd x11-ssh-askpass-%{aversion}
%configure --libexecdir=%{_libexecdir}/openssh
xmkmf -a
make
popd
%endif# Define a variable to toggle gnome1/gtk2 building.  This is necessary
# because RPM doesn't handle nested %if statements.
%if %{gtk2}gtk2=yes
%elsegtk2=no
%endif%if ! %{no_gnome_askpass}
pushd contrib
if [ $gtk2 = yes ] ; thenmake gnome-ssh-askpass2mv gnome-ssh-askpass2 gnome-ssh-askpass
elsemake gnome-ssh-askpass1mv gnome-ssh-askpass1 gnome-ssh-askpass
fi
popd
%endif%install
rm -rf $RPM_BUILD_ROOT
mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/ssh
mkdir -p -m755 $RPM_BUILD_ROOT%{_libexecdir}/openssh
mkdir -p -m755 $RPM_BUILD_ROOT%{_var}/empty/sshdmake install DESTDIR=$RPM_BUILD_ROOTinstall -d $RPM_BUILD_ROOT/etc/pam.d/
install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
install -d $RPM_BUILD_ROOT%{_libexecdir}/openssh
%if %{build6x}
install -m644 contrib/redhat/sshd.pam     $RPM_BUILD_ROOT/etc/pam.d/sshd
%else
install -m644 contrib/redhat/sshd.pam     $RPM_BUILD_ROOT/etc/pam.d/sshd
%endif
install -m755 contrib/redhat/sshd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/sshd
install -m755 contrib/ssh-copy-id $RPM_BUILD_ROOT/usr/bin/ssh-copy-id%if ! %{no_x11_askpass}
install x11-ssh-askpass-%{aversion}/x11-ssh-askpass $RPM_BUILD_ROOT%{_libexecdir}/openssh/x11-ssh-askpass
ln -s x11-ssh-askpass $RPM_BUILD_ROOT%{_libexecdir}/openssh/ssh-askpass
%endif%if ! %{no_gnome_askpass}
install contrib/gnome-ssh-askpass $RPM_BUILD_ROOT%{_libexecdir}/openssh/gnome-ssh-askpass
%endif%if ! %{scard}rm -f $RPM_BUILD_ROOT/usr/share/openssh/Ssh.bin
%endif%if ! %{no_gnome_askpass}
install -m 755 -d $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/
install -m 755 contrib/redhat/gnome-ssh-askpass.csh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/
install -m 755 contrib/redhat/gnome-ssh-askpass.sh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/
%endifperl -pi -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT%{_mandir}/man*/*%clean
rm -rf $RPM_BUILD_ROOT%triggerun server -- ssh-server
if [ "$1" != 0 -a -r /var/run/sshd.pid ] ; thentouch /var/run/sshd.restart
fi%triggerun server -- openssh-server < 2.5.0p1
# Count the number of HostKey and HostDsaKey statements we have.
gawk	'BEGIN {IGNORECASE=1}/^hostkey/ || /^hostdsakey/ {sawhostkey = sawhostkey + 1}END {exit sawhostkey}' /etc/ssh/sshd_config
# And if we only found one, we know the client was relying on the old default
# behavior, which loaded the the SSH2 DSA host key when HostDsaKey wasn't
# specified.  Now that HostKey is used for both SSH1 and SSH2 keys, specifying
# one nullifies the default, which would have loaded both.
if [ $? -eq 1 ] ; thenecho HostKey /etc/ssh/ssh_host_rsa_key >> /etc/ssh/sshd_configecho HostKey /etc/ssh/ssh_host_dsa_key >> /etc/ssh/sshd_config
fi%triggerpostun server -- ssh-server
if [ "$1" != 0 ] ; then/sbin/chkconfig --add sshdif test -f /var/run/sshd.restart ; thenrm -f /var/run/sshd.restart/sbin/service sshd start > /dev/null 2>&1 || :fi
fi%pre server
%{_sbindir}/groupadd -r -g %{sshd_gid} sshd 2>/dev/null || :
%{_sbindir}/useradd -d /var/empty/sshd -s /bin/false -u %{sshd_uid} \-g sshd -M -r sshd 2>/dev/null || :%post server
/sbin/chkconfig --add sshd%postun server
/sbin/service sshd condrestart > /dev/null 2>&1 || :%preun server
if [ "$1" = 0 ]
then/sbin/service sshd stop > /dev/null 2>&1 || :/sbin/chkconfig --del sshd
fi%files
%defattr(-,root,root)
%doc CREDITS ChangeLog INSTALL LICENCE OVERVIEW README* PROTOCOL* TODO
%attr(0755,root,root) %{_bindir}/scp
%attr(0644,root,root) %{_mandir}/man1/scp.1*
%attr(0755,root,root) %dir %{_sysconfdir}/ssh
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/ssh/moduli
%if ! %{rescue}
%attr(0755,root,root) %{_bindir}/ssh-keygen
%attr(0644,root,root) %{_mandir}/man1/ssh-keygen.1*
%attr(0755,root,root) %dir %{_libexecdir}/openssh
%attr(4711,root,root) %{_libexecdir}/openssh/ssh-keysign
%attr(0755,root,root) %{_libexecdir}/openssh/ssh-pkcs11-helper
%attr(0755,root,root) %{_libexecdir}/openssh/ssh-sk-helper
%attr(0644,root,root) %{_mandir}/man8/ssh-keysign.8*
%attr(0644,root,root) %{_mandir}/man8/ssh-pkcs11-helper.8*
%attr(0644,root,root) %{_mandir}/man8/ssh-sk-helper.8*
%endif
%if %{scard}
%attr(0755,root,root) %dir %{_datadir}/openssh
%attr(0644,root,root) %{_datadir}/openssh/Ssh.bin
%endif%files clients
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/ssh
%attr(0644,root,root) %{_mandir}/man1/ssh.1*
%attr(0644,root,root) %{_mandir}/man5/ssh_config.5*
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/ssh/ssh_config
%if ! %{rescue}
%attr(2755,root,nobody) %{_bindir}/ssh-agent
%attr(0755,root,root) %{_bindir}/ssh-add
%attr(0755,root,root) %{_bindir}/ssh-keyscan
%attr(0755,root,root) %{_bindir}/sftp
%attr(0755,root,root) %{_bindir}/ssh-copy-id
%attr(0644,root,root) %{_mandir}/man1/ssh-agent.1*
%attr(0644,root,root) %{_mandir}/man1/ssh-add.1*
%attr(0644,root,root) %{_mandir}/man1/ssh-keyscan.1*
%attr(0644,root,root) %{_mandir}/man1/sftp.1*
%endif%if ! %{rescue}
%files server
%defattr(-,root,root)
%dir %attr(0111,root,root) %{_var}/empty/sshd
%attr(0755,root,root) %{_sbindir}/sshd
%attr(0755,root,root) %{_libexecdir}/openssh/sftp-server
%attr(0644,root,root) %{_mandir}/man8/sshd.8*
%attr(0644,root,root) %{_mandir}/man5/moduli.5*
%attr(0644,root,root) %{_mandir}/man5/sshd_config.5*
%attr(0644,root,root) %{_mandir}/man8/sftp-server.8*
%attr(0755,root,root) %dir %{_sysconfdir}/ssh
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/ssh/sshd_config
%attr(0600,root,root) %config(noreplace) /etc/pam.d/sshd
%attr(0755,root,root) %config /etc/rc.d/init.d/sshd
%endif%if ! %{no_x11_askpass}
%files askpass
%defattr(-,root,root)
%doc x11-ssh-askpass-%{aversion}/README
%doc x11-ssh-askpass-%{aversion}/ChangeLog
%doc x11-ssh-askpass-%{aversion}/SshAskpass*.ad
%{_libexecdir}/openssh/ssh-askpass
%attr(0755,root,root) %{_libexecdir}/openssh/x11-ssh-askpass
%endif%if ! %{no_gnome_askpass}
%files askpass-gnome
%defattr(-,root,root)
%attr(0755,root,root) %config %{_sysconfdir}/profile.d/gnome-ssh-askpass.*
%attr(0755,root,root) %{_libexecdir}/openssh/gnome-ssh-askpass
%endif%changelog
* Thu Oct 28 2021 Damien Miller <djm@mindrot.org>
- Remove remaining traces of --with-md5-passwords* Mon Jul 20 2020 Damien Miller <djm@mindrot.org>
- Add ssh-sk-helper and corresponding manual page.* Sat Feb 10 2018 Darren Tucker <dtucker@dtucker.net>
- Update openssl-devel dependency to match current requirements.
- Handle Fedora >=6 openssl 1.0 compat libs.
- Remove SSH1 from description.
- Don't strip binaries at build time so that debuginfo package can becreated.
* Sun Nov 16 2014 Nico Kadel-Garcia <nakdel@gmail.com>
- Add '--mandir' and '--with-mantype' for RHEL 5 compatibility
- Add 'dist' option to 'ver' so package names reflect OS at build time
- Always include x11-ssh-askpass tarball in SRPM
- Add openssh-x11-aspass BuildRequires for libXT-devel, imake, gtk2-devel
- Discard 'K5DIR' reporting, not usable inside 'mock' for RHEL 5 compatibility
- Discard obsolete '--with-rsh' configure option
- Update openssl-devel dependency to 0.9.8f, as found in autoconf
* Wed Jul 14 2010 Tim Rice <tim@multitalents.net>
- test for skip_x11_askpass (line 77) should have been for no_x11_askpass
* Mon Jun 2 2003 Damien Miller <djm@mindrot.org>
- Remove noip6 option. This may be controlled at run-time in client configfile using new AddressFamily directive
* Mon May 12 2003 Damien Miller <djm@mindrot.org>
- Don't install profile.d scripts when not building with GNOME/GTK askpass(patch from bet@rahul.net)* Tue Oct 01 2002 Damien Miller <djm@mindrot.org>
- Install ssh-agent setgid nobody to prevent ptrace() key theft attacks* Mon Sep 30 2002 Damien Miller <djm@mindrot.org>
- Use contrib/ Makefile for building askpass programs* Fri Jun 21 2002 Damien Miller <djm@mindrot.org>
- Merge in spec changes from seba@iq.pl (Sebastian Pachuta)
- Add new {ssh,sshd}_config.5 manpages
- Add new ssh-keysign program and remove setuid from ssh client* Fri May 10 2002 Damien Miller <djm@mindrot.org>
- Merge in spec changes from RedHat, reorgansie a little
- Add Privsep user, group and directory* Thu Mar  7 2002 Nalin Dahyabhai <nalin@redhat.com> 3.1p1-2
- bump and grind (through the build system)* Thu Mar  7 2002 Nalin Dahyabhai <nalin@redhat.com> 3.1p1-1
- require sharutils for building (mindrot #137)
- require db1-devel only when building for 6.x (#55105), which probably won'twork anyway (3.1 requires OpenSSL 0.9.6 to build), but what the heck
- require pam-devel by file (not by package name) again
- add Markus's patch to compile with OpenSSL 0.9.5a (fromhttp://bugzilla.mindrot.org/show_bug.cgi?id=141) and apply it if we'rebuilding for 6.x* Thu Mar  7 2002 Nalin Dahyabhai <nalin@redhat.com> 3.1p1-0
- update to 3.1p1* Tue Mar  5 2002 Nalin Dahyabhai <nalin@redhat.com> SNAP-20020305
- update to SNAP-20020305
- drop debug patch, fixed upstream* Wed Feb 20 2002 Nalin Dahyabhai <nalin@redhat.com> SNAP-20020220
- update to SNAP-20020220 for testing purposes (you've been warned, if there'sanything to be warned about, gss patches won't apply, I don't mind)* Wed Feb 13 2002 Nalin Dahyabhai <nalin@redhat.com> 3.0.2p1-3
- add patches from Simon Wilkinson and Nicolas Williams for GSSAPI keyexchange, authentication, and named key support* Wed Jan 23 2002 Nalin Dahyabhai <nalin@redhat.com> 3.0.2p1-2
- remove dependency on db1-devel, which has just been swallowed up wholeby gnome-libs-devel* Sat Dec 29 2001 Nalin Dahyabhai <nalin@redhat.com>
- adjust build dependencies so that build6x actually works right (fixfrom Hugo van der Kooij)* Tue Dec  4 2001 Nalin Dahyabhai <nalin@redhat.com> 3.0.2p1-1
- update to 3.0.2p1* Fri Nov 16 2001 Nalin Dahyabhai <nalin@redhat.com> 3.0.1p1-1
- update to 3.0.1p1* Tue Nov 13 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to current CVS (not for use in distribution)* Thu Nov  8 2001 Nalin Dahyabhai <nalin@redhat.com> 3.0p1-1
- merge some of Damien Miller <djm@mindrot.org> changes from the upstream3.0p1 spec file and init script* Wed Nov  7 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to 3.0p1
- update to x11-ssh-askpass 1.2.4.1
- change build dependency on a file from pam-devel to the pam-devel package
- replace primes with moduli* Thu Sep 27 2001 Nalin Dahyabhai <nalin@redhat.com> 2.9p2-9
- incorporate fix from Markus Friedl's advisory for IP-based authorization bugs
* Thu Sep 13 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.9p2-8
- Merge changes to rescue build from current sysadmin survival cd
* Thu Sep  6 2001 Nalin Dahyabhai <nalin@redhat.com> 2.9p2-7
- fix scp's server's reporting of file sizes, and build with the properpreprocessor define to get large-file capable open(), stat(), etc.(sftp has been doing this correctly all along) (#51827)
- configure without --with-ipv4-default on RHL 7.x and newer (#45987,#52247)
- pull cvs patch to fix support for /etc/nologin for non-PAM logins (#47298)
- mark profile.d scriptlets as config files (#42337)
- refer to Jason Stone's mail for zsh workaround for exit-hanging quasi-bug
- change a couple of log() statements to debug() statements (#50751)
- pull cvs patch to add -t flag to sshd (#28611)
- clear fd_sets correctly (one bit per FD, not one byte per FD) (#43221)* Mon Aug 20 2001 Nalin Dahyabhai <nalin@redhat.com> 2.9p2-6
- add db1-devel as a BuildPrerequisite (noted by Hans Ecke)* Thu Aug 16 2001 Nalin Dahyabhai <nalin@redhat.com>
- pull cvs patch to fix remote port forwarding with protocol 2* Thu Aug  9 2001 Nalin Dahyabhai <nalin@redhat.com>
- pull cvs patch to add session initialization to no-pty sessions
- pull cvs patch to not cut off challengeresponse auth needlessly
- refuse to do X11 forwarding if xauth isn't there, handy if you enableit by default on a system that doesn't have X installed (#49263)* Wed Aug  8 2001 Nalin Dahyabhai <nalin@redhat.com>
- don't apply patches to code we don't intend to build (spotted by Matt Galgoci)* Mon Aug  6 2001 Nalin Dahyabhai <nalin@redhat.com>
- pass OPTIONS correctly to initlog (#50151)* Wed Jul 25 2001 Nalin Dahyabhai <nalin@redhat.com>
- switch to x11-ssh-askpass 1.2.2* Wed Jul 11 2001 Nalin Dahyabhai <nalin@redhat.com>
- rebuild in new environment* Mon Jun 25 2001 Nalin Dahyabhai <nalin@redhat.com>
- disable the gssapi patch* Mon Jun 18 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to 2.9p2
- refresh to a new version of the gssapi patch* Thu Jun  7 2001 Nalin Dahyabhai <nalin@redhat.com>
- change Copyright: BSD to License: BSD
- add Markus Friedl's unverified patch for the cookie file deletion problemso that we can verify it
- drop patch to check if xauth is present (was folded into cookie patch)
- don't apply gssapi patches for the errata candidate
- clear supplemental groups list at startup* Fri May 25 2001 Nalin Dahyabhai <nalin@redhat.com>
- fix an error parsing the new default sshd_config
- add a fix from Markus Friedl (via openssh-unix-dev) for ssh-keygen notdealing with comments right* Thu May 24 2001 Nalin Dahyabhai <nalin@redhat.com>
- add in Simon Wilkinson's GSSAPI patch to give it some testing in-house,to be removed before the next beta cycle because it's a big departurefrom the upstream version* Thu May  3 2001 Nalin Dahyabhai <nalin@redhat.com>
- finish marking strings in the init script for translation
- modify init script to source /etc/sysconfig/sshd and pass $OPTIONS to sshdat startup (change merged from openssh.com init script, originally byPekka Savola)
- refuse to do X11 forwarding if xauth isn't there, handy if you enableit by default on a system that doesn't have X installed* Wed May  2 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to 2.9
- drop various patches that came from or went upstream or to or from CVS* Wed Apr 18 2001 Nalin Dahyabhai <nalin@redhat.com>
- only require initscripts 5.00 on 6.2 (reported by Peter Bieringer)* Sun Apr  8 2001 Preston Brown <pbrown@redhat.com>
- remove explicit openssl requirement, fixes builddistro issue
- make initscript stop() function wait until sshd really dead to avoidraces in condrestart* Mon Apr  2 2001 Nalin Dahyabhai <nalin@redhat.com>
- mention that challengereponse supports PAM, so disabling password doesn'tlimit users to pubkey and rsa auth (#34378)
- bypass the daemon() function in the init script and call initlog directly,because daemon() won't start a daemon it detects is already running (likeopen connections)
- require the version of openssl we had when we were built* Fri Mar 23 2001 Nalin Dahyabhai <nalin@redhat.com>
- make do_pam_setcred() smart enough to know when to establish creds andwhen to reinitialize them
- add in a couple of other fixes from Damien for inclusion in the errata* Thu Mar 22 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to 2.5.2p2
- call setcred() again after initgroups, because the "creds" could actuallybe group memberships* Tue Mar 20 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to 2.5.2p1 (includes endianness fixes in the rijndael implementation)
- don't enable challenge-response by default until we find a way to nothave too many userauth requests (we may make up to six pubkey and up tothree password attempts as it is)
- remove build dependency on rsh to match openssh.com's packages more closely* Sat Mar  3 2001 Nalin Dahyabhai <nalin@redhat.com>
- remove dependency on openssl -- would need to be too precise* Fri Mar  2 2001 Nalin Dahyabhai <nalin@redhat.com>
- rebuild in new environment* Mon Feb 26 2001 Nalin Dahyabhai <nalin@redhat.com>
- Revert the patch to move pam_open_session.
- Init script and spec file changes from Pekka Savola. (#28750)
- Patch sftp to recognize '-o protocol' arguments. (#29540)* Thu Feb 22 2001 Nalin Dahyabhai <nalin@redhat.com>
- Chuck the closing patch.
- Add a trigger to add host keys for protocol 2 to the config file, now thatconfiguration file syntax requires us to specify it with HostKey if wespecify any other HostKey values, which we do.* Tue Feb 20 2001 Nalin Dahyabhai <nalin@redhat.com>
- Redo patch to move pam_open_session after the server setuid()s to the user.
- Rework the nopam patch to use be picked up by autoconf.* Mon Feb 19 2001 Nalin Dahyabhai <nalin@redhat.com>
- Update for 2.5.1p1.
- Add init script mods from Pekka Savola.
- Tweak the init script to match the CVS contrib script more closely.
- Redo patch to ssh-add to try to adding both identity and id_dsa to also tryadding id_rsa.* Fri Feb 16 2001 Nalin Dahyabhai <nalin@redhat.com>
- Update for 2.5.0p1.
- Use $RPM_OPT_FLAGS instead of -O when building gnome-ssh-askpass
- Resync with parts of Damien Miller's openssh.spec from CVS, includingupdate of x11 askpass to 1.2.0.
- Only require openssl (don't prereq) because we generate keys in the initscript now.* Tue Feb 13 2001 Nalin Dahyabhai <nalin@redhat.com>
- Don't open a PAM session until we've forked and become the user (#25690).
- Apply Andrew Bartlett's patch for letting pam_authenticate() know whichhost the user is attempting a login from.
- Resync with parts of Damien Miller's openssh.spec from CVS.
- Don't expose KbdInt responses in debug messages (from CVS).
- Detect and handle errors in rsa_{public,private}_decrypt (from CVS).
* Wed Feb  7 2001 Trond Eivind Glomsrxd <teg@redhat.com>
- i18n-tweak to initscript.
* Tue Jan 23 2001 Nalin Dahyabhai <nalin@redhat.com>
- More gettextizing.
- Close all files after going into daemon mode (needs more testing).
- Extract patch from CVS to handle auth banners (in the client).
- Extract patch from CVS to handle compat weirdness.
* Fri Jan 19 2001 Nalin Dahyabhai <nalin@redhat.com>
- Finish with the gettextizing.
* Thu Jan 18 2001 Nalin Dahyabhai <nalin@redhat.com>
- Fix a bug in auth2-pam.c (#23877)
- Gettextize the init script.
* Wed Dec 20 2000 Nalin Dahyabhai <nalin@redhat.com>
- Incorporate a switch for using PAM configs for 6.x, just in case.
* Tue Dec  5 2000 Nalin Dahyabhai <nalin@redhat.com>
- Incorporate Bero's changes for a build specifically for rescue CDs.* Wed Nov 29 2000 Nalin Dahyabhai <nalin@redhat.com>
- Don't treat pam_setcred() failure as fatal unless pam_authenticate() hassucceeded, to allow public-key authentication after a failure with "none"authentication.  (#21268)
* Tue Nov 28 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to x11-askpass 1.1.1. (#21301)
- Don't second-guess fixpaths, which causes paths to get fixed twice. (#21290)* Mon Nov 27 2000 Nalin Dahyabhai <nalin@redhat.com>
- Merge multiple PAM text messages into subsequent prompts when possible whendoing keyboard-interactive authentication.* Sun Nov 26 2000 Nalin Dahyabhai <nalin@redhat.com>
- Disable the built-in MD5 password support.  We're using PAM.
- Take a crack at doing keyboard-interactive authentication with PAM, andenable use of it in the default client configuration so that the clientwill try it when the server disallows password authentication.
- Build with debugging flags.  Build root policies strip all binaries anyway.
* Tue Nov 21 2000 Nalin Dahyabhai <nalin@redhat.com>
- Use DESTDIR instead of %%makeinstall.
- Remove /usr/X11R6/bin from the path-fixing patch.
* Mon Nov 20 2000 Nalin Dahyabhai <nalin@redhat.com>
- Add the primes file from the latest snapshot to the main package (#20884).
- Add the dev package to the prereq list (#19984).
- Remove the default path and mimic login's behavior in the server itself.* Fri Nov 17 2000 Nalin Dahyabhai <nalin@redhat.com>
- Resync with conditional options in Damien Miller's .spec file for an errata.
- Change libexecdir from %%{_libexecdir}/ssh to %%{_libexecdir}/openssh.
* Tue Nov  7 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to OpenSSH 2.3.0p1.
- Update to x11-askpass 1.1.0.
- Enable keyboard-interactive authentication.
* Mon Oct 30 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to ssh-askpass-x11 1.0.3.
- Change authentication related messages to be private (#19966).
* Tue Oct 10 2000 Nalin Dahyabhai <nalin@redhat.com>
- Patch ssh-keygen to be able to list signatures for DSA public key filesit generates.
* Thu Oct  5 2000 Nalin Dahyabhai <nalin@redhat.com>
- Add BuildRequires on /usr/include/security/pam_appl.h to be sure we alwaysbuild PAM authentication in.
- Try setting SSH_ASKPASS if gnome-ssh-askpass is installed.
- Clean out no-longer-used patches.
- Patch ssh-add to try to add both identity and id_dsa, and to error onlywhen neither exists.
* Mon Oct  2 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update x11-askpass to 1.0.2. (#17835)
- Add BuildRequiress for /bin/login and /usr/bin/rsh so that configure willalways find them in the right place. (#17909)
- Set the default path to be the same as the one supplied by /bin/login, butadd /usr/X11R6/bin. (#17909)
- Try to handle obsoletion of ssh-server more cleanly.  Package namesare different, but init script name isn't. (#17865)* Wed Sep  6 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to 2.2.0p1. (#17835)
- Tweak the init script to allow proper restarting. (#18023)* Wed Aug 23 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to 20000823 snapshot.
- Change subpackage requirements from %%{version} to %%{version}-%%{release}
- Back out the pipe patch.* Mon Jul 17 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to 2.1.1p4, which includes fixes for config file parsing problems.
- Move the init script back.
- Add Damien's quick fix for wackiness.
* Wed Jul 12 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to 2.1.1p3, which includes fixes for X11 forwarding and strtok().
* Thu Jul  6 2000 Nalin Dahyabhai <nalin@redhat.com>
- Move condrestart to server postun.
- Move key generation to init script.
- Actually use the right patch for moving the key generation to the init script.
- Clean up the init script a bit.
* Wed Jul  5 2000 Nalin Dahyabhai <nalin@redhat.com>
- Fix X11 forwarding, from mail post by Chan Shih-Ping Richard.
* Sun Jul  2 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to 2.1.1p2.
- Use of strtok() considered harmful.
* Sat Jul  1 2000 Nalin Dahyabhai <nalin@redhat.com>
- Get the build root out of the man pages.
* Thu Jun 29 2000 Nalin Dahyabhai <nalin@redhat.com>
- Add and use condrestart support in the init script.
- Add newer initscripts as a prereq.
* Tue Jun 27 2000 Nalin Dahyabhai <nalin@redhat.com>
- Build in new environment (release 2)
- Move -clients subpackage to Applications/Internet group
* Fri Jun  9 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to 2.2.1p1
* Sat Jun  3 2000 Nalin Dahyabhai <nalin@redhat.com>
- Patch to build with neither RSA nor RSAref.
- Miscellaneous FHS-compliance tweaks.
- Fix for possibly-compressed man pages.
* Wed Mar 15 2000 Damien Miller <djm@ibs.com.au>
- Updated for new location
- Updated for new gnome-ssh-askpass build
* Sun Dec 26 1999 Damien Miller <djm@mindrot.org>
- Added Jim Knoble's <jmknoble@pobox.com> askpass* Mon Nov 15 1999 Damien Miller <djm@mindrot.org>
- Split subpackages further based on patch from jim knoble <jmknoble@pobox.com>* Sat Nov 13 1999 Damien Miller <djm@mindrot.org>
- Added 'Obsoletes' directives* Tue Nov 09 1999 Damien Miller <djm@ibs.com.au>
- Use make install
- Subpackages* Mon Nov 08 1999 Damien Miller <djm@ibs.com.au>
- Added links for slogin
- Fixed perms on manpages* Sat Oct 30 1999 Damien Miller <djm@ibs.com.au>
- Renamed init script* Fri Oct 29 1999 Damien Miller <djm@ibs.com.au>
- Back to old binary names* Thu Oct 28 1999 Damien Miller <djm@ibs.com.au>
- Use autoconf
- New binary names* Wed Oct 27 1999 Damien Miller <djm@ibs.com.au>
- Initial RPMification, based on Jan "Yenya" Kasprzak's <kas@fi.muni.cz> spec.

構建rpm包

上訴準備工作完成之后,執行如下命令構建rpm包

rpmbuild -ba ~/rpmbuild/SPECS/openssh.spec

看到如下結果為打包成功
在這里插入圖片描述
進入打包后的rpm包目錄,將相關的包上傳到需要升級的服務器安裝即可

cd /root/rpmbuild/RPMS/aarch64

在這里插入圖片描述

安裝升級OpenSSH

正常我們安裝openssh-9.6p1-1.uel20.aarch64.rpmopenssh-clients-9.6p1-1.uel20.aarch64.rpmopenssh-server-9.6p1-1.uel20.aarch64.rpm三個包即可,將這三個包上傳至目標服務器進行安裝

scp openssh-9.6p1-1.uel20.aarch64.rpm openssh-clients-9.6p1-1.uel20.aarch64.rpm openssh-server-9.6p1-1.uel20.aarch64.rpm uat90:~/

安裝OpenSSH

注意:安裝前先進行備份,安裝過程如果失敗,容易造成無法再通過ssh連接,建議安裝一個telnet保持長鏈接,同時建議看兩個以上終端連接上再進行升級,以免安裝失敗無法恢復sshd服務正常

停用和卸載舊版本sshd服務

查看當前版本

ssh -Vrpm -qa | grep openssh

在這里插入圖片描述
卸載

# 停用
systemctl stop sshd
# 卸載當前安裝版本
rpm -e --nodeps openssh-server openssh-clients openssh openssh-help

安裝

注意:安裝前先進行備份,安裝過程如果失敗,容易造成無法再通過ssh連接,建議安裝一個telnet保持長鏈接,同時建議看兩個以上終端連接上再進行升級,以免安裝失敗無法恢復sshd服務正常

rpm -Uvh --oldpackage --nodeps openssh-9.6p1-1.uel20.aarch64.rpm openssh-clients-9.6p1-1.uel20.aarch64.rpm openssh-server-9.6p1-1.uel20.aarch64.rpm

在這里插入圖片描述

修改配置

vim /etc/ssh/sshd_config
PasswordAuthentication yes
UsePAM no

在這里插入圖片描述
在這里插入圖片描述
可以執行如下命令將所有配置追加到/etc/ssh/sshd_config配置中

cat >> /etc/ssh/sshd_config << EOF
PasswordAuthentication yes
UsePAM no
LogLevel VERBOSE
IgnoreRhosts yes
HostbasedAuthentication no
PermitEmptyPasswords no
PermitUserEnvironment no
ClientAliveCountMax 0
AllowTcpForwarding no
AllowAgentForwarding no
GatewayPorts no
PermitTunnel no
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
Banner /etc/issue.net
StrictModes yes
PubkeyAuthentication yes
Protocol 2
LoginGraceTime 60
IgnoreUserKnownHosts yes
Ciphers aes128-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
MACs hmac-sha2-512,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,umac-128@openssh.com
PubkeyAcceptedKeyTypes ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-512
Banner none
VersionAddendum none
EOF

測試配置是否正確?,如下命令如果不報錯則沒有問題

sshd -t

啟動

systemctl start sshdsystemctl status sshd

在這里插入圖片描述

檢查版本

檢查版本,從其他機器測試登錄是否正常

ssh -V

在這里插入圖片描述
至此完成統信UOS操作系統aarch64自制OpenSSH的rpm包從8.2p1到9.6p1版本升級

下載rpm資源包安裝

如果你的系統剛好是統信uel20.aarch64,同時OpenSSH是9.6p1以下版本,可以直接下載我編譯好的rpm安裝包
在這里插入圖片描述
下載openssh-9.6p1-1.uel20.aarch64-rpm安裝包.zip,包中內容如下
在這里插入圖片描述
upgrade_openssh.sh升級腳本

#!/bin/bash# OpenSSH 升級腳本
# 適用于 aarch64 架構,升級安裝 OpenSSH 至 9.6p1# 顏色定義
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # 恢復默認顏色# 日志函數
log() {echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
}# 錯誤處理函數
handle_error() {log "${RED}錯誤: $1${NC}"exit 1
}# 確認函數
confirm() {read -p "$1 [y/N] " responsecase "$response" in[yY][eE][sS]|[yY]) true;;*)false;;esac
}# 版本比較函數
version_compare() {# 提取版本號(如 9.6p1)local current=$(echo "$1" | grep -oP 'OpenSSH_\K[^,]+')local target="9.6p1"log "當前版本: $current"log "目標版本: $target"# 比較主版本號local current_major=$(echo "$current" | grep -oP '^\d+\.\d+')local target_major=$(echo "$target" | grep -oP '^\d+\.\d+')if (( $(echo "$current_major < $target_major" | bc -l) )); thenreturn 0  # 需要升級elif (( $(echo "$current_major > $target_major" | bc -l) )); thenreturn 1  # 無需升級else# 主版本相同,比較次要版本local current_minor=$(echo "$current" | grep -oP 'p\d+$')local target_minor=$(echo "$target" | grep -oP 'p\d+$')if [[ "$current_minor" < "$target_minor" ]]; thenreturn 0  # 需要升級elsereturn 1  # 無需升級fifi
}# 主函數
main() {log "${YELLOW}開始 OpenSSH 升級腳本${NC}"# 檢查是否為root用戶if [ "$(id -u)" -ne 0 ]; thenhandle_error "請使用root用戶運行此腳本"fi# 檢查系統架構ARCH=$(uname -m)if [ "$ARCH" != "aarch64" ]; thenlog "${YELLOW}警告: 檢測到架構為 $ARCH,此腳本專為 aarch64 設計${NC}"if ! confirm "是否繼續執行?"; thenlog "${YELLOW}腳本已取消${NC}"exit 0fifi# 保存當前目錄CURRENT_DIR=$(pwd)# 創建工作目錄WORK_DIR="/opt/openssh-upgrade"mkdir -p "$WORK_DIR" || handle_error "無法創建工作目錄 $WORK_DIR"cd "$WORK_DIR" || handle_error "無法進入工作目錄 $WORK_DIR"log "${GREEN}==== 步驟 1: 查看當前 OpenSSH 版本 ====${NC}"CURRENT_SSHD=$(sshd -V 2>&1 | head -1)if [[ -z "$CURRENT_SSHD" ]]; thenlog "${YELLOW}未找到已安裝的 OpenSSH,將進行全新安裝${NC}"elselog "當前安裝的 OpenSSH 版本:"log "$CURRENT_SSHD"# 驗證配置if ! sshd -t 2>/dev/null; thenlog "${YELLOW}當前 OpenSSH 配置驗證失敗,升級后需檢查配置${NC}"fi# 版本比較if version_compare "$CURRENT_SSHD"; thenlog "${GREEN}當前版本低于 9.6p1,繼續升級${NC}"elselog "${YELLOW}當前版本已大于或等于 9.6p1,無需升級${NC}"log "${YELLOW}當前版本: $CURRENT_SSHD${NC}"exit 0fifiif ! confirm "是否繼續進行升級?"; thenlog "${YELLOW}腳本已取消${NC}"exit 0filog "${GREEN}==== 步驟 2: 卸載當前 OpenSSH ====${NC}"log "停止 sshd 服務..."systemctl stop sshd || log "${YELLOW}無法停止 sshd 服務,可能未運行${NC}"log "卸載 OpenSSH 包..."rpm -e --nodeps openssh-server openssh-clients openssh openssh-help 2>/dev/null || log "${YELLOW}卸載現有 OpenSSH 包失敗或包不存在${NC}"log "${GREEN}==== 步驟 3: 安裝新的 OpenSSH ====${NC}"RPM_DIR="$CURRENT_DIR"  # 假設RPM包在當前目錄RPM_FILES=("openssh-9.6p1-1.uel20.aarch64.rpm""openssh-clients-9.6p1-1.uel20.aarch64.rpm""openssh-server-9.6p1-1.uel20.aarch64.rpm")# 檢查RPM文件是否存在MISSING_RPMS=()for file in "${RPM_FILES[@]}"; doif [ ! -f "$RPM_DIR/$file" ]; thenMISSING_RPMS+=("$file")fidoneif [ ${#MISSING_RPMS[@]} -gt 0 ]; thenlog "${RED}錯誤: 以下RPM文件不存在:${NC}"for file in "${MISSING_RPMS[@]}"; dolog "  - $file"donehandle_error "請確保RPM文件在 $RPM_DIR 目錄中"filog "安裝新的 OpenSSH 包..."rpm -Uvh --oldpackage --nodeps "$RPM_DIR/"openssh-*.rpm || handle_error "安裝 OpenSSH RPM 包失敗"log "${GREEN}==== 步驟 4: 修改 SSH 配置 ====${NC}"SSH_CONFIG="/etc/ssh/sshd_config"BACKUP_CONFIG="$SSH_CONFIG.bak.$(date '+%Y%m%d%H%M%S')"log "備份現有配置文件到 $BACKUP_CONFIG"cp "$SSH_CONFIG" "$BACKUP_CONFIG" || handle_error "無法備份 SSH 配置文件"log "追加新配置到 $SSH_CONFIG"cat >> "$SSH_CONFIG" << EOF# 由升級腳本添加的安全配置
PasswordAuthentication yes
UsePAM no
LogLevel VERBOSE
IgnoreRhosts yes
HostbasedAuthentication no
PermitEmptyPasswords no
PermitUserEnvironment no
ClientAliveCountMax 0
AllowTcpForwarding no
AllowAgentForwarding no
GatewayPorts no
PermitTunnel no
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
Banner /etc/issue.net
StrictModes yes
PubkeyAuthentication yes
Protocol 2
LoginGraceTime 60
IgnoreUserKnownHosts yes
Ciphers aes128-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
MACs hmac-sha2-512,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,umac-128@openssh.com
PubkeyAcceptedKeyTypes ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-512
Banner none
VersionAddendum none
EOFlog "${GREEN}==== 步驟 5: 啟動并驗證 SSH ====${NC}"log "啟動 sshd 服務..."systemctl start sshd || handle_error "啟動 sshd 服務失敗"log "檢查服務狀態..."systemctl status sshd --no-pager || log "${YELLOW}sshd 服務狀態檢查失敗,但服務可能仍在運行${NC}"log "驗證升級后的版本..."sshd -t || handle_error "升級后的 OpenSSH 配置驗證失敗"log "${GREEN}==== 步驟 6: 檢查并設置開機自啟動 ====${NC}"if [[ $(systemctl is-enabled sshd) != "enabled" ]]; thenlog "${YELLOW}sshd 服務未設置開機自啟動,正在設置...${NC}"systemctl enable sshd || log "${RED}警告: 無法設置 sshd 開機自啟動,請手動設置${NC}"elselog "${GREEN}sshd 服務已設置開機自啟動${NC}"filog "重啟 sshd 服務..."systemctl restart sshd || handle_error "重啟 sshd 服務失敗"log "${GREEN}==== OpenSSH 升級完成 ====${NC}"log "新版本: $(sshd -V 2>&1 | head -1)"log "配置文件: $SSH_CONFIG"log "備份文件: $BACKUP_CONFIG"log "${GREEN}請確保能夠通過 SSH 連接到服務器后再關閉當前會話${NC}"log "${YELLOW}腳本參考:http://blog.csdn.net/UberSoldier/article/details/148410819${NC}"
}# 執行主函數
main

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/82409.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/82409.shtml
英文地址,請注明出處:http://en.pswp.cn/web/82409.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

CI/CD 持續集成、持續交付、持續部署

CI/CD 是 持續集成&#xff08;Continuous Integration&#xff09; 和 持續交付/持續部署&#xff08;Continuous Delivery/Deployment&#xff09; 的縮寫&#xff0c;代表現代軟件開發中通過自動化流程快速、可靠地構建、測試和發布代碼的實踐。其核心目標是 減少人工干預、…

Spring Boot 應用中實現配置文件敏感信息加密解密方案

Spring Boot 應用中實現配置文件敏感信息加密解密方案 背景與挑戰 &#x1f6a9;一、設計目標 &#x1f3af;二、整體啟動流程 &#x1f504;三、方案實現詳解 ??3.1 配置解密入口&#xff1a;EnvironmentPostProcessor3.2 通用解密工具類&#xff1a;EncryptionTool 四、快速…

OpenCV CUDA模塊特征檢測------角點檢測的接口createMinEigenValCorner()

操作系統&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 編程語言&#xff1a;C11 算法描述 該函數創建一個 基于最小特征值&#xff08;Minimum Eigenvalue&#xff09;的角點響應計算對象&#xff0c;這是另一種經典的角點檢測方法&…

性能優化 - 理論篇:CPU、內存、I/O診斷手段

文章目錄 Pre引言1. CPU 性能瓶頸1.1 top 命令 —— 多維度 CPU 使用率指標1.2 負載&#xff08;load&#xff09;——任務排隊情況1.3 vmstat 命令 —— CPU 繁忙與等待 2. 內存性能瓶頸2.1 操作系統層面的內存分布2.2 top 命令 —— VIRT / RES / SHR 三個關鍵列2.3 CPU 緩存…

GPIO的內部結構與功能解析

一、GPIO總體結構 總體構成 1.APB2(外設總線) APB2總線是微控制器內部連接CPU與外設&#xff08;如GPIO&#xff09;的總線&#xff0c;負責CPU對GPIO寄存器的讀寫訪問&#xff0c;支持低速外設通信 2.寄存器 控制GPIO的配置&#xff08;輸入/輸出模式、上拉/下拉等&#x…

汽車總線分析總結(CAN、LIN、FlexRay、MOST、車載以太網)

目錄 一、汽車總線技術概述 二、主流汽車總線技術對比分析 1. CAN總線&#xff08;Controller Area Network&#xff09; 2. LIN總線&#xff08;Local Interconnect Network&#xff09; 3. FlexRay總線 4. MOST總線&#xff08;Media Oriented Systems Transport&#x…

WordPress 6.5版本帶來的新功能

WordPress 6.5正式上線了&#xff01;WordPress團隊再一次為我們帶來了許多新的改進。在全球開發者的共同努力下&#xff0c;WordPress推出了許多新的功能&#xff0c;本文將對其進行詳細總結。 Hostease的虛擬主機現已支持一鍵安裝最新版本的WordPress。對于想要體驗WordPres…

【vue+ts】找不到模塊“./App.vue”或其相應的類型聲明

報錯&#xff1a;找不到模塊“./App.vue”或其相應的類型聲明。 原因&#xff1a;typescript只能理解.ts文件&#xff0c;無法理解.vue文件。 解決&#xff1a;在src/env.d.ts下添加&#xff1a; /// <reference types"vite/client" /> // 三斜線引用告訴編譯…

Nginx+Tomcat 負載均衡群集

目錄 一&#xff0c;部署Tomcat 1&#xff0c;案例概述 2&#xff0c;案例前置知識點 &#xff08;1&#xff09;Tomcat簡介 &#xff08;2&#xff09;應用場景 3&#xff0c;案例實施 3.1&#xff0c;實施準備 &#xff08;1&#xff09;關閉firewalld防火墻 &#…

Spring Boot Actuator未授權訪問漏洞修復

方案1&#xff1a;在網關的配置文件里增加以下配置 management:endpoints:web:exposure:include: []enabled-by-default: falseendpoint:health:show-details: ALWAYS 方案二&#xff1a;直接在nginx配置攔截actuator相關接口 location /actuator { return 403; …

動態規劃之網格圖模型(二)

文章目錄 動態規劃之網格圖模型&#xff08;二&#xff09;LeetCode 931. 下降路徑最小和思路Golang 代碼 LeetCode 2684. 矩陣中移動的最大次數思路Golang 代碼 LeetCode 2304. 網格中的最小路徑代價思路Golang 代碼 LeetCode 1289. 下降路徑最小和 II思路Golang 代碼 LeetCod…

React 編譯器

&#x1f916; 作者簡介&#xff1a;水煮白菜王&#xff0c;一位前端勸退師 &#x1f47b; &#x1f440; 文章專欄&#xff1a; 前端專欄 &#xff0c;記錄一下平時在博客寫作中&#xff0c;總結出的一些開發技巧和知識歸納總結?。 感謝支持&#x1f495;&#x1f495;&#…

mac下通過anaconda安裝Python

本次分享mac下通過anaconda安裝Python、Jupyter Notebook、R。 anaconda安裝 點擊&#x1f449;https://www.anaconda.com/download&#xff0c; 點擊Mac系統安裝包&#xff0c; 選擇Mac芯片&#xff1a;蘋果芯片 or intel芯片&#xff0c; 選擇蘋果芯片圖形界面安裝&#x…

Pandas 技術解析:從數據結構到應用場景的深度探索

序 我最早用Python做大數據項目時&#xff0c;接觸最早的就是Pandas了。覺得對于IT技術人員而言&#xff0c;它是可以屬于多場景的存在&#xff0c;因為它的本身就是數據驅動的技術生態中&#xff0c;對于軟件工程師而言&#xff0c;它是快速構建數據處理管道的基石&#xff1…

【循環神經網絡RNN第一期】循環神經網絡RNN原理概述

目錄 &#x1f9e0; 什么是循環神經網絡&#xff08;RNN&#xff09;&#xff1f;&#x1f501; RNN 的結構圖&#x1f504; RNN 的“記憶”與問題RNN梯度推導 &#x1f9ec; LSTM&#xff1a;解決長期依賴問題&#x1f9f1; LSTM 的核心結構LSTM總結 參考 人類在思考的時候&am…

代碼隨想錄算法訓練營 Day60 圖論Ⅹ Bellmen_ford 系列算法

圖論 題目 94. 城市間貨物運輸 I Bellmen_ford 隊列優化算法 SPFA 大家可以發現 Bellman_ford 算法每次松弛 都是對所有邊進行松弛。 但真正有效的松弛&#xff0c;是基于已經計算過的節點在做的松弛。 本圖中&#xff0c;對所有邊進行松弛&#xff0c;真正有效的松弛&#…

Juce實現Table自定義

Juce實現Table自定義 一.總體展示概及概述 在項目中Juce中TableList往往無法滿足用戶需求&#xff0c;頭部和背景及背景顏色設置以及在Cell中添加自定義按鈕&#xff0c;所以需要自己實現自定義TabelList&#xff0c;該示例是展示實現自定義TableList&#xff0c;實現自定義標…

C++ set數據插入、set數據查找、set數據刪除、set數據統計、set排序規則、代碼練習1、2

set數據插入&#xff0c;代碼見下 #include<iostream> #include<set> #include<vector>using namespace std;void printSet(const set<int>& s) {for (set<int>::const_iterator it s.begin(); it ! s.end(); it) {cout << *it <…

深度學習賦能圖像識別:技術、應用與展望

論文&#xff1a; 一、引言? 1.1 研究背景與意義? 在當今數字化時代&#xff0c;圖像作為信息的重要載體&#xff0c;廣泛存在于各個領域。圖像識別技術旨在讓計算機理解和識別圖像內容&#xff0c;將圖像中的對象、場景、行為等信息轉化為計算機能夠處理的符號或數據 &am…

深入解析C++引用:從別名機制到函數特性實踐

1.C引用 1.1引用的概念和定義 引用不是新定義?個變量&#xff0c;而是給已存在變量取了?個別名&#xff0c;編譯器不會為引用變量開辟內存空間&#xff0c;它和它引用的變量共用同?塊內存空間。比如四大名著中林沖&#xff0c;他有一個外號叫豹子頭&#xff0c;類比到C里就…