制作OpenSSH 9.6 for BCLinux-for-Euler-21.10LTS的rpm升级包

47 篇文章 0 订阅
33 篇文章 3 订阅

OpenSSH作为操作系统底层管理平台软件,需要保持更新以免遭受安全攻击,编译生成rpm包是生产环境中批量升级的最佳途径。本文在国产BCLinux-for-Euler-21.10系统上完成OpenSSH 9.6的编译工作。

一、编译环境

参见本人前文最小化安装BCLinux-for-Euler-21.10-dvd-x86_64-230731版

1、系统版本
[root@localhost ~]# cat /etc/os-release  
NAME="BigCloud Enterprise Linux"
VERSION="21.10 (LTS-SP2)"
ID="bclinux"
VERSION_ID="21.10"
PRETTY_NAME="BigCloud Enterprise Linux For Euler 21.10 LTS"
ANSI_COLOR="0;31"

[root@localhost ~]# uname -r
4.19.90-2107.6.0.0208.16.oe1.bclinux.x86_64
2、openssh版本
[root@localhost ~]# rpm -qa |grep openssh
openssh-help-8.2p1-10.oe1.noarch
openssh-server-8.2p1-10.oe1.x86_64
openssh-clients-8.2p1-10.oe1.x86_64
openssh-8.2p1-10.oe1.x86_64
[root@localhost ~]# ssh -V
OpenSSH_8.2p1, OpenSSL 1.1.1f  31 Mar 2020
[root@localhost ~]# sshd -V
unknown option -- V
OpenSSH_8.2p1, OpenSSL 1.1.1f  31 Mar 2020
usage: sshd [-46DdeiqTt] [-C connection_spec] [-c host_cert_file]
            [-E log_file] [-f config_file] [-g login_grace_time]
            [-h host_key_file] [-o option] [-p port] [-u len]
3、去除授权管理以便安装包
[root@localhost ~]# yum install tree -y
服务器检查结果:
***信息***您的授权码是无效的,请获得正确的授权码来注册大云Linux操作系统。您可以使用'bclinux-license -g'命令获得机器码,然后与我们联系帮您产生订阅从而获得正确的授权码。
[root@localhost ~]# rpm -qa |grep license
bclinux-license-manager-4.0-1.oe1.bclinux.x86_64
[root@localhost ~]# rpm -e bclinux-license-manager-4.0-1.oe1.bclinux.x86_64
Removed /etc/systemd/system/multi-user.target.wants/license-check.timer.
[root@localhost ~]# yum install tree -y  
... 
上次元数据过期检查:0:00:01 前,执行于 2024年02月01日 星期四 09时20分21秒。
依赖关系解决。
=========================================================================================================================================================
 Package                          Architecture                       Version                                    Repository                          Size
=========================================================================================================================================================
安装:
 tree                             x86_64                             1.8.0-1.oe1                                baseos                              52 k

事务概要
=========================================================================================================================================================
安装  1 软件包
...
已安装:
  tree-1.8.0-1.oe1.x86_64                                                                                                                                

完毕!
4、准备编译目录
[root@localhost ~]# cd ~
[root@localhost ~]# mkdir -p rpmbuild/{SOURCES,SPECS} 
[root@localhost ~]# tree rpmbuild/
rpmbuild/
├── SOURCES
└── SPECS

2 directories, 0 files
5、准备源码包
5.1、源包版本

官网地址 当前版本

 - SHA1 (openssh-9.6.tar.gz) = a6d4cb69811e879e2f158c2e597fd9f444b26506
 - SHA256 (openssh-9.6.tar.gz) = nejPUhSnG1R1sOmIBi/t+HMNvsRqfN/DJgjwIU2tvqg=

 - SHA1 (openssh-9.6p1.tar.gz) = de300d09ec79fdbf37de4e6672cce4161439f2c3
 - SHA256 (openssh-9.6p1.tar.gz) = kQIRwHJVqMWtZUORtA7lmABxDdgRndU2LeCThap6d3w=

附加程序:

x11-ssh-askpass-1.2.4.1

openssl-1.1.1w

5.2、下载实作
[root@localhost ~]# cd rpmbuild/SOURCES/
[root@localhost SOURCES]# wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz --no-check-certificat
--2024-02-01 10:35:59--  https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz
正在解析主机 cdn.openbsd.org (cdn.openbsd.org)... 151.101.79.52, 2a04:4e42:8c::820
正在连接 cdn.openbsd.org (cdn.openbsd.org)|151.101.79.52|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1857862 (1.8M) [application/octet-stream]
正在保存至: “openssh-9.6p1.tar.gz”

openssh-9.6p1.tar.gz                   100%[=========================================================================>]   1.77M  1.66MB/s  用时 1.1s    

2024-02-01 10:36:01 (1.66 MB/s) - 已保存 “openssh-9.6p1.tar.gz” [1857862/1857862])

[root@localhost SOURCES]# 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 --no-check-certificat
--2024-02-01 10:36:43--  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
正在解析主机 src.fedoraproject.org (src.fedoraproject.org)... 38.145.60.21, 38.145.60.20
正在连接 src.fedoraproject.org (src.fedoraproject.org)|38.145.60.21|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:29229 (29K) [application/x-gzip]
正在保存至: “x11-ssh-askpass-1.2.4.1.tar.gz”

x11-ssh-askpass-1.2.4.1.tar.gz         100%[=========================================================================>]  28.54K   113KB/s  用时 0.3s    

2024-02-01 10:36:45 (113 KB/s) - 已保存 “x11-ssh-askpass-1.2.4.1.tar.gz” [29229/29229])

[root@localhost SOURCES]# wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
--2024-02-01 10:37:08--  https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
正在解析主机 www.openssl.org (www.openssl.org)... 34.36.58.177, 2600:1901:0:1812::
正在连接 www.openssl.org (www.openssl.org)|34.36.58.177|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9893384 (9.4M) [application/x-tar]
正在保存至: “openssl-1.1.1w.tar.gz”

openssl-1.1.1w.tar.gz                  100%[=========================================================================>]   9.43M   990KB/s  用时 9.8s    

2024-02-01 10:37:19 (981 KB/s) - 已保存 “openssl-1.1.1w.tar.gz” [9893384/9893384])

[root@localhost SOURCES]# vi sshd.pam.oe2110
[root@localhost SOURCES]# cat sshd.pam.oe2110 
#%PAM-1.0
auth       substack     password-auth
auth       include      postlogin
account    required     pam_sepermit.so
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    required     pam_namespace.so
session    optional     pam_keyinit.so force revoke
session    optional     pam_motd.so
session    include      password-auth
session    include      postlogin
[root@localhost SOURCES]# ll
总用量 12M
-rw-r--r-- 1 root root 1.8M 12月 18 23:06 openssh-9.6p1.tar.gz
-rw-r--r-- 1 root root 9.5M  1月 30 22:48 openssl-1.1.1w.tar.gz
-rw-r--r-- 1 root root  727  2月  1 10:38 sshd.pam.oe2110
-rw-r--r-- 1 root root  29K  6月 26  2004 x11-ssh-askpass-1.2.4.1.tar.gz
6、安装编译所需软件包
[root@localhost SOURCES]# cd ../SPECS
[root@localhost SPECS]# yum install rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel -y
上次元数据过期检查:0:24:17 前,执行于 2024年02月01日 星期四 10时17分14秒。
软件包 rpm-build-4.15.1-28.oe1.x86_64 已安装。
软件包 gcc-7.3.0-20210605.39.oe1.x86_64 已安装。
软件包 perl-devel-4:5.28.3-6.oe1.x86_64 已安装。
依赖关系解决。
=========================================================================================================================================================
 Package                                   Architecture                 Version                                       Repository                    Size
=========================================================================================================================================================
安装:
 openssl-devel                             x86_64                       1:1.1.1t-11.oe1.bclinux                       extras                       1.7 M
 pam-devel                                 x86_64                       1.4.0-5.oe1                                   baseos                        21 k
 zlib-devel                                x86_64                       1.2.11-17.oe1                                 baseos                        90 k
...
已升级:
  cpp-7.3.0-2020033101.49.oe1.x86_64            gcc-7.3.0-2020033101.49.oe1.x86_64                 gcc-c++-7.3.0-2020033101.49.oe1.x86_64               
  libgomp-7.3.0-2020033101.49.oe1.x86_64        libstdc++-7.3.0-2020033101.49.oe1.x86_64           libstdc++-devel-7.3.0-2020033101.49.oe1.x86_64       
  openssl-1:1.1.1t-11.oe1.bclinux.x86_64        openssl-libs-1:1.1.1t-11.oe1.bclinux.x86_64        python3-rpm-4.15.1-30.oe1.x86_64                     
  rpm-4.15.1-30.oe1.x86_64                      rpm-build-4.15.1-30.oe1.x86_64                     rpm-libs-4.15.1-30.oe1.x86_64                        

已安装:
  e2fsprogs-devel-1.45.6-2.oe1.x86_64                     keyutils-libs-devel-1.6.3-1.oe1.x86_64            krb5-devel-1.18.2-3.oe1.x86_64              
  libselinux-devel-3.1-3.oe1.x86_64                       libsepol-devel-3.1-4.oe1.x86_64                   libverto-devel-0.3.1-2.oe1.x86_64           
  openssl-devel-1:1.1.1t-11.oe1.bclinux.x86_64            pam-devel-1.4.0-5.oe1.x86_64                      pcre2-devel-10.35-1.oe1.x86_64              
  zlib-devel-1.2.11-17.oe1.x86_64                        

完毕!
[root@localhost SPECS]#
7、 编写spec文件
[root@localhost SPECS]# vi openssh.spec
[root@localhost SPECS]# cat openssh.spec 
%{?!opensslver: %global opensslver 1.1.1w}
%{?!opensshver: %global opensshver 9.6p1}.1
%define static_openssl 1
 
# wheather to build openssl
%global no_build_openssl 0
 
#if defined openssl_dir, don't build it
%{?openssl_dir:%global no_build_openssl 1}
 
%global ver %{?opensshver}
%global rel %{?opensshpkgrel}
 
# 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 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, with MD5)? (1=yes 0=no)
%global rescue 0
%{?build_rescue:%global rescue 1}
 
# Turn off some stuff for resuce builds
%if %{rescue}
%global kerberos5 0
%endif
 
Summary: 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
Source2: sshd.pam.oe2110
%if ! %{no_build_openssl}
Source3: https://www.openssl.org/source/openssl-%{opensslver}.tar.gz
%endif
License: BSD
Group: Applications/Internet
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
Obsoletes: ssh
%if %{build6x}
PreReq: initscripts >= 5.00
%else
Requires: initscripts >= 5.20
%endif
BuildRequires: perl
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
%if %{gtk2}
BuildRequires: gtk2-devel
%endif
%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
 
%package server
Summary: The OpenSSH server daemon.
Group: System Environment/Daemons
Obsoletes: ssh-server
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
 
%package askpass-gnome
Summary: A passphrase dialog for OpenSSH, X, and GNOME.
Group: Applications/Internet
Requires: openssh = %{version}-%{release}
Obsoletes: ssh-extras
 
%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
 
%if ! %{no_build_openssl}
%define openssl_dir %{_builddir}/%{name}-%{version}/openssl
mkdir -p openssl
tar xfz %{SOURCE3} --strip-components=1 -C openssl
pushd openssl
./config shared zlib -fPIC
make %{?_smp_mflags}
popd
%endif
 
%build
%if %{rescue}
CFLAGS="$RPM_OPT_FLAGS -Os"; export CFLAGS
%endif
 
export LD_LIBRARY_PATH="%{openssl_dir}"
%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 \
        --with-md5-passwords \
        --mandir=%{_mandir} \
        --with-mantype=man \
        --disable-strip \
        --with-ssl-dir="%{openssl_dir}" \
%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
perl -pi -e "s|-lcrypto|%{openssl_dir}/libcrypto.a -lpthread|g" Makefile
%endif
 
make %{?_smp_mflags}
 
%if ! %{no_x11_askpass}
pushd x11-ssh-askpass-%{aversion}
%configure --libexecdir=%{_libexecdir}/openssh
xmkmf -a
make -j
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
%else
        gtk2=no
%endif
 
%if ! %{no_gnome_askpass}
pushd contrib
if [ $gtk2 = yes ] ; then
        make gnome-ssh-askpass2
        mv gnome-ssh-askpass2 gnome-ssh-askpass
else
        make gnome-ssh-askpass1
        mv 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/sshd
 
make install DESTDIR=$RPM_BUILD_ROOT
echo -e 'PubkeyAcceptedAlgorithms +ssh-rsa\nUsePAM yes\nPermitRootLogin yes\nUseDNS no' >> $RPM_BUILD_ROOT/etc/ssh/sshd_config
install -d $RPM_BUILD_ROOT/etc/pam.d/
install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
install -d $RPM_BUILD_ROOT%{_libexecdir}/openssh
install -m755 contrib/ssh-copy-id $RPM_BUILD_ROOT/usr/bin/ssh-copy-id
install -m644 %{SOURCE2}     $RPM_BUILD_ROOT/etc/pam.d/sshd
install -m755 contrib/redhat/sshd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/sshd
 
%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/
%endif
 
perl -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 ] ; then
        touch /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 ] ; then
        echo HostKey /etc/ssh/ssh_host_rsa_key >> /etc/ssh/sshd_config
        echo HostKey /etc/ssh/ssh_host_dsa_key >> /etc/ssh/sshd_config
fi
 
%triggerpostun server -- ssh-server
if [ "$1" != 0 ] ; then
        /sbin/chkconfig --add sshd
        if test -f /var/run/sshd.restart ; then
                rm -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(0755,root,root) %{_bindir}/ssh-copy-id
%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(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
[root@localhost SPECS]# 

二、编译实作

1、编译
[root@localhost SPECS]# rpmbuild  -bb openssh.spec
警告:行 100:It's not recommended to have unversioned Obsoletes:Obsoletes: ssh
警告:行 136:It's not recommended to have unversioned Obsoletes:Obsoletes: ssh-clients
警告:行 141:It's not recommended to have unversioned Obsoletes:Obsoletes: ssh-server
警告:行 151:It's not recommended to have unversioned Obsoletes:Obsoletes: ssh-extras
警告:行 157:It's not recommended to have unversioned Obsoletes:Obsoletes: ssh-extras
正在执行(%prep):/bin/sh -e /var/tmp/rpm-tmp.dxHeFm
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf openssh-9.6p1
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/openssh-9.6p1.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd openssh-9.6p1
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ mkdir -p openssl
+ tar xfz /root/rpmbuild/SOURCES/openssl-1.1.1w.tar.gz --strip-components=1 -C openssl
+ pushd openssl
~/rpmbuild/BUILD/openssh-9.6p1/openssl ~/rpmbuild/BUILD/openssh-9.6p1
+ ./config shared zlib -fPIC
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1w (0x1010117fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
...
Obsoletes: ssh-server
处理文件:openssh-debuginfo-9.6p1-1.oe1.bclinux.x86_64
Provides: openssh-debuginfo = 9.6p1-1.oe1.bclinux openssh-debuginfo(x86-64) = 9.6p1-1.oe1.bclinux
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Recommends: openssh-debugsource(x86-64) = 9.6p1-1.oe1.bclinux
处理文件:openssh-debugsource-9.6p1-1.oe1.bclinux.x86_64
Provides: openssh-debugsource = 9.6p1-1.oe1.bclinux openssh-debugsource(x86-64) = 9.6p1-1.oe1.bclinux
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
检查未打包文件:/usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/openssh-9.6p1-1.oe1.bclinux.x86_64
已写至:/root/rpmbuild/RPMS/x86_64/openssh-debuginfo-9.6p1-1.oe1.bclinux.x86_64.rpm
已写至:/root/rpmbuild/RPMS/x86_64/openssh-9.6p1-1.oe1.bclinux.x86_64.rpm
已写至:/root/rpmbuild/RPMS/x86_64/openssh-clients-9.6p1-1.oe1.bclinux.x86_64.rpm
已写至:/root/rpmbuild/RPMS/x86_64/openssh-server-9.6p1-1.oe1.bclinux.x86_64.rpm
已写至:/root/rpmbuild/RPMS/x86_64/openssh-debugsource-9.6p1-1.oe1.bclinux.x86_64.rpm
正在执行(%clean):/bin/sh -e /var/tmp/rpm-tmp.6uMirq
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd openssh-9.6p1
+ rm -rf /root/rpmbuild/BUILDROOT/openssh-9.6p1-1.oe1.bclinux.x86_64
+ RPM_EC=0
++ jobs -p
+ exit 0
2、保存最终文件 
[root@localhost SPECS]# cd /opt
[root@localhost opt]# mkdir openssh-9.6p1-oe2110
[root@localhost opt]# cd openssh-9.6p1-oe2110/
[root@localhost openssh-9.6p1-oe2110]# cp /root/rpmbuild/RPMS/x86_64/* .
[root@localhost openssh-9.6p1-oe2110]# ll
总用量 16M
-rw-r--r-- 1 root root 4.8M  2月  1 13:58 openssh-9.6p1-1.oe1.bclinux.x86_64.rpm
-rw-r--r-- 1 root root 4.9M  2月  1 13:58 openssh-clients-9.6p1-1.oe1.bclinux.x86_64.rpm
-rw-r--r-- 1 root root 3.4M  2月  1 13:58 openssh-debuginfo-9.6p1-1.oe1.bclinux.x86_64.rpm
-rw-r--r-- 1 root root 788K  2月  1 13:58 openssh-debugsource-9.6p1-1.oe1.bclinux.x86_64.rpm
-rw-r--r-- 1 root root 1.5M  2月  1 13:58 openssh-server-9.6p1-1.oe1.bclinux.x86_64.rpm

三、升级测试

1、直接更新
[root@localhost openssh-9.6p1-oe2110]# yum update *
上次元数据过期检查:0:39:57 前,执行于 2024年02月01日 星期四 13时19分14秒。
软件包 openssh-debuginfo 未安装,无法更新。
未找到匹配的参数: openssh-debuginfo-9.6p1-1.oe1.bclinux.x86_64.rpm
软件包 openssh-debugsource 未安装,无法更新。
未找到匹配的参数: openssh-debugsource-9.6p1-1.oe1.bclinux.x86_64.rpm
依赖关系解决。
=========================================================================================================================================================
 Package                               Architecture                 Version                                     Repository                          Size
=========================================================================================================================================================
升级:
 openssh                               x86_64                       9.6p1-1.oe1.bclinux                         @commandline                       4.8 M
 openssh-clients                       x86_64                       9.6p1-1.oe1.bclinux                         @commandline                       4.9 M
 openssh-server                        x86_64                       9.6p1-1.oe1.bclinux                         @commandline                       1.5 M

事务概要
=========================================================================================================================================================
升级  3 软件包

总计:11 M
确定吗?[y/N]: y
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
错误:事物测试失败:
  file /usr/share/man/man1/scp.1.gz from install of openssh-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man1/ssh-keygen.1.gz from install of openssh-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man8/ssh-keysign.8.gz from install of openssh-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man8/ssh-pkcs11-helper.8.gz from install of openssh-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man8/ssh-sk-helper.8.gz from install of openssh-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man1/sftp.1.gz from install of openssh-clients-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man1/ssh-add.1.gz from install of openssh-clients-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man1/ssh-agent.1.gz from install of openssh-clients-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man1/ssh-keyscan.1.gz from install of openssh-clients-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man1/ssh.1.gz from install of openssh-clients-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man5/ssh_config.5.gz from install of openssh-clients-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man5/moduli.5.gz from install of openssh-server-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man5/sshd_config.5.gz from install of openssh-server-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man8/sftp-server.8.gz from install of openssh-server-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch
  file /usr/share/man/man8/sshd.8.gz from install of openssh-server-9.6p1-1.oe1.bclinux.x86_64 conflicts with file from package openssh-help-8.2p1-10.oe1.noarch

提示openssh-help依赖

2、卸载openssh-help软件包
[root@localhost openssh-9.6p1-oe2110]# rpm -e --nodeps openssh-help-8.2p1-10.oe1.noarch 
3、再次更新
[root@localhost openssh-9.6p1-oe2110]# yum update *                           
上次元数据过期检查:0:42:58 前,执行于 2024年02月01日 星期四 13时19分14秒。
软件包 openssh-debuginfo 未安装,无法更新。
未找到匹配的参数: openssh-debuginfo-9.6p1-1.oe1.bclinux.x86_64.rpm
软件包 openssh-debugsource 未安装,无法更新。
未找到匹配的参数: openssh-debugsource-9.6p1-1.oe1.bclinux.x86_64.rpm
依赖关系解决。
=========================================================================================================================================================
 Package                               Architecture                 Version                                     Repository                          Size
=========================================================================================================================================================
升级:
 openssh                               x86_64                       9.6p1-1.oe1.bclinux                         @commandline                       4.8 M
 openssh-clients                       x86_64                       9.6p1-1.oe1.bclinux                         @commandline                       4.9 M
 openssh-server                        x86_64                       9.6p1-1.oe1.bclinux                         @commandline                       1.5 M

事务概要
=========================================================================================================================================================
升级  3 软件包
...
已升级:
  openssh-9.6p1-1.oe1.bclinux.x86_64           openssh-clients-9.6p1-1.oe1.bclinux.x86_64           openssh-server-9.6p1-1.oe1.bclinux.x86_64          

完毕!
4、重启服务
[root@localhost openssh-9.6p1-oe2110]# systemctl restart sshd
[root@localhost openssh-9.6p1-oe2110]# systemctl status sshd 
● sshd.service - SYSV: OpenSSH server daemon
   Loaded: loaded (/etc/rc.d/init.d/sshd; generated)
   Active: active (running) since Thu 2024-02-01 14:03:36 CST; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 68882 ExecStart=/etc/rc.d/init.d/sshd start (code=exited, status=0/SUCCESS)
 Main PID: 68892 (sshd)
    Tasks: 1
   Memory: 900.0K
   CGroup: /system.slice/sshd.service
           └─68892 sshd: /usr/sbin/sshd [listener] 0 of 10-100 startups

2月 01 14:03:36 localhost.localdomain systemd[1]: sshd.service: Succeeded.
2月 01 14:03:36 localhost.localdomain systemd[1]: Stopped SYSV: OpenSSH server daemon.
2月 01 14:03:36 localhost.localdomain systemd[1]: Starting SYSV: OpenSSH server daemon...
2月 01 14:03:36 localhost.localdomain sshd[68882]: Starting sshd:[  确定  ]
2月 01 14:03:36 localhost.localdomain systemd[1]: sshd.service: Can't open PID file /run/sshd.pid (yet?) after start: No such file or directory
2月 01 14:03:36 localhost.localdomain sshd[68892]: Server listening on 0.0.0.0 port 22.
2月 01 14:03:36 localhost.localdomain sshd[68892]: Server listening on :: port 22.
2月 01 14:03:36 localhost.localdomain systemd[1]: Started SYSV: OpenSSH server daemon.
[root@localhost openssh-9.6p1-oe2110]# 
5、远程登录验证
Last login: Thu Feb  1 09:15:01 2024 from 192.168.80.1
[AAAA@localhost ~]$ su -
密码:
TMOUT=0
上一次登录: 四 2月  1 09:15:05 CST 2024 pts/0 上
 ____  _        ____ _                 _
| __ )(_) __ _ / ___| | ___  _   _  __| |
|  _ \| |/ _` | |   | |/ _ \| | | |/ _` |
| |_) | | (_| | |___| | (_) | |_| | (_| |
|____/|_|\__, |\____|_|\___/ \__,_|\__,_|
         |___/
 _____       _                       _            _     _
| ____|_ __ | |_ ___ _ __ _ __  _ __(_)___  ___  | |   (_)_ __  _   ___  __
|  _| | '_ \| __/ _ \ '__| '_ \| '__| / __|/ _ \ | |   | | '_ \| | | \ \/ /
| |___| | | | ||  __/ |  | |_) | |  | \__ \  __/ | |___| | | | | |_| |>  <
|_____|_| |_|\__\___|_|  | .__/|_|  |_|___/\___| |_____|_|_| |_|\__,_/_/\_\
                         |_|
 _____             _____       _              ____   _     _  ___  
|  ___|__  _ __   | ____|_   _| | ___ _ __   |___ \ / |   / |/ _ \
| |_ / _ \| '__|  |  _| | | | | |/ _ \ '__|    __) || |   | | | | |
|  _| (_) | |     | |__ | |_| | |  __/ |      / __/|| | _ | | |_| |
|_|  \___/|_|     |_____|\__,_|_|\___|_|     |_____||_|(_)|_|\___/


Welcome to BigCloud Enterprise Linux For Euler 21.10 (GNU/Linux 4.19.90-2107.6.0.0208.16.oe1.bclinux.x86_64 x86_64)

System information as of Thu Feb  1 14:04:04 CST 2024

  * System CPU load:    0.01 0.02 0.00        * System   uptime:         14:04:04 up  4:57  
  * Active sessions:    3                     * Memory    usage:         210 / 723 MB
  * Processes count:    144

  * Contact US   :
        MAIL : 4001100865@cmss.chinamobile.com / TEL : 4001-10086-5

[root@localhost ~]# TMOUT=0
[root@localhost ~]# ssh -V
OpenSSH_9.6p1, OpenSSL 1.1.1w  11 Sep 2023
[root@localhost ~]# sshd -V
OpenSSH_9.6p1, OpenSSL 1.1.1w  11 Sep 2023
[root@localhost ~]# rpm -qa |grep openssh
openssh-server-9.6p1-1.oe1.bclinux.x86_64
openssh-clients-9.6p1-1.oe1.bclinux.x86_64
openssh-9.6p1-1.oe1.bclinux.x86_64
[root@localhost ~]# 

  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代先生.重庆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值