• 编译CentOS Stream 8系统的OpenSSHV9.4rpm安装包


     目前OpenSSH版本已至9.4,其作为操作系统底层管理平台软件,需要保持更新以免遭受安全攻击,编译生成rpm包是生产环境中批量升级的最佳途径。编译软件包时与当前的运行环境有较大关系,请注意本安装包系在CentOS Stream 8原生系统纯净系统下编译完成的。实际本软件包可用于Anolis OS8.*/BClinux8U8等el8运行环境的Linux系统升级openssh。

     一、准备编译环境:

     1、发布一台虚拟机,最小化安装CentOS Stream 8,查看系统信息如下:

    1. [root@localhost ~]# cat /etc/os-release
    2. NAME="CentOS Stream"
    3. VERSION="8"
    4. ID="centos"
    5. ID_LIKE="rhel fedora"
    6. VERSION_ID="8"
    7. PLATFORM_ID="platform:el8"
    8. PRETTY_NAME="CentOS Stream 8"
    9. ANSI_COLOR="0;31"
    10. CPE_NAME="cpe:/o:centos:centos:8"
    11. HOME_URL="https://centos.org/"
    12. BUG_REPORT_URL="https://bugzilla.redhat.com/"
    13. REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
    14. REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

     2、查看系统所带openssl的版本信息:

    1. [root@localhost ~]# ssh -V
    2. OpenSSH_8.0p1, OpenSSL 1.1.1k FIPS 25 Mar 2021
    3. [root@localhost ~]# openssl version
    4. OpenSSL 1.1.1k FIPS 25 Mar 2021
    5. [root@localhost ~]# rpm -qa|grep openssh
    6. openssh-server-8.0p1-12.el8.x86_64
    7. openssh-8.0p1-12.el8.x86_64
    8. openssh-clients-8.0p1-12.el8.x86_64

     3、查看系统源:

    1. [root@localhost ~]# cd /etc/yum.repos.d/
    2. [root@localhost yum.repos.d]# ll
    3. 总用量 44
    4. -rw-r--r--. 1 root root 713 1月 19 2022 CentOS-Stream-AppStream.repo
    5. -rw-r--r--. 1 root root 698 1月 19 2022 CentOS-Stream-BaseOS.repo
    6. -rw-r--r--. 1 root root 316 1月 19 2022 CentOS-Stream-Debuginfo.repo
    7. -rw-r--r--. 1 root root 698 1月 19 2022 CentOS-Stream-Extras.repo
    8. -rw-r--r--. 1 root root 734 1月 19 2022 CentOS-Stream-HighAvailability.repo
    9. -rw-r--r--. 1 root root 696 1月 19 2022 CentOS-Stream-Media.repo
    10. -rw-r--r--. 1 root root 683 1月 19 2022 CentOS-Stream-NFV.repo
    11. -rw-r--r--. 1 root root 718 1月 19 2022 CentOS-Stream-PowerTools.repo
    12. -rw-r--r--. 1 root root 690 1月 19 2022 CentOS-Stream-RealTime.repo
    13. -rw-r--r--. 1 root root 748 1月 19 2022 CentOS-Stream-ResilientStorage.repo
    14. -rw-r--r--. 1 root root 1771 1月 19 2022 CentOS-Stream-Sources.repo
    15. [root@localhost yum.repos.d]# mkdir old
    16. [root@localhost yum.repos.d]# mv *.repo old
    17. [root@localhost SOURCES]# mount /dev/cdrom /media
    18. mount: /media: WARNING: device write-protected, mounted read-only.
    19. [root@localhost SOURCES]# ll /media
    20. 总用量 30
    21. dr-xr-xr-x. 4 root root 2048 2月 15 2022 AppStream
    22. dr-xr-xr-x. 4 root root 2048 2月 15 2022 BaseOS
    23. dr-xr-xr-x. 3 root root 2048 2月 15 2022 EFI
    24. dr-xr-xr-x. 3 root root 2048 2月 15 2022 images
    25. dr-xr-xr-x. 2 root root 2048 2月 15 2022 isolinux
    26. -r--r--r--. 1 root root 18092 9月 14 2021 LICENSE
    27. -r--r--r--. 1 root root 88 2月 15 2022 media.repo
    28. -r--r--r--. 1 root root 883 2月 15 2022 TRANS.TBL
    29. [root@localhost SOURCES]# vi /etc/yum.repos.d/http.repo
    30. [root@localhost SOURCES]# cat /etc/yum.repos.d/http.repo
    31. [os]
    32. name=os
    33. baseurl=file:///media/BaseOS
    34. gpgcheck=0
    35. enabled=1
    36. [app]
    37. name=app
    38. baseurl=file:///media/AppStream
    39. gpgcheck=0
    40. enabled=1
    41. [root@localhost SOURCES]# dnf repolist
    42. 仓库 id 仓库名称
    43. app app
    44. os os

     4、准备相关目录及工具

    1. [root@localhost ~]# cd ~
    2. [root@localhost ~]# mkdir -p rpmbuild/{SOURCES,SPECS}
    3. [root@localhost ~]# dnf install wget tree -y
    4. os 838 kB/s | 4.6 MB 00:05
    5. app 710 kB/s | 8.4 MB 00:12
    6. 上次元数据过期检查:0:00:01 前,执行于 2023年09月11日 星期一 04时02分54秒。
    7. 依赖关系解决。
    8. =========================================================================================================================================================
    9. 软件包 架构 版本 仓库 大小
    10. =========================================================================================================================================================
    11. 安装:
    12. tree x86_64 1.7.0-15.el8 os 59 k
    13. wget x86_64 1.19.5-10.el8 app 734 k
    14. 安装依赖关系:
    15. libmetalink x86_64 0.1.3-7.el8 os 32 k
    16. 事务概要
    17. =========================================================================================================================================================
    18. 安装 3 软件包
    19. 总下载:825 k
    20. 安装大小:2.9 M
    21. 下载软件包:
    22. (1/3): libmetalink-0.1.3-7.el8.x86_64.rpm 116 kB/s | 32 kB 00:00
    23. (2/3): tree-1.7.0-15.el8.x86_64.rpm 192 kB/s | 59 kB 00:00
    24. (3/3): wget-1.19.5-10.el8.x86_64.rpm 532 kB/s | 734 kB 00:01
    25. ---------------------------------------------------------------------------------------------------------------------------------------------------------
    26. 总计 589 kB/s | 825 kB 00:01
    27. 运行事务检查
    28. 事务检查成功。
    29. 运行事务测试
    30. 事务测试成功。
    31. 运行事务
    32. 准备中 : 1/1
    33. 安装 : libmetalink-0.1.3-7.el8.x86_64 1/3
    34. 安装 : wget-1.19.5-10.el8.x86_64 2/3
    35. 运行脚本: wget-1.19.5-10.el8.x86_64 2/3
    36. 安装 : tree-1.7.0-15.el8.x86_64 3/3
    37. 运行脚本: tree-1.7.0-15.el8.x86_64 3/3
    38. 验证 : libmetalink-0.1.3-7.el8.x86_64 1/3
    39. 验证 : tree-1.7.0-15.el8.x86_64 2/3
    40. 验证 : wget-1.19.5-10.el8.x86_64 3/3
    41. 已安装:
    42. libmetalink-0.1.3-7.el8.x86_64 tree-1.7.0-15.el8.x86_64 wget-1.19.5-10.el8.x86_64
    43. 完毕!

    5、 准备源文件

    1. [root@localhost ~]# cd rpmbuild/SOURCES/
    2. [root@localhost SOURCES]# wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.4p1.tar.gz --no-check-certificate
    3. --2023-09-11 04:04:04-- https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.4p1.tar.gz
    4. 正在解析主机 ftp.openbsd.org (ftp.openbsd.org)... 199.185.178.81
    5. 正在连接 ftp.openbsd.org (ftp.openbsd.org)|199.185.178.81|:443... 已连接。
    6. 已发出 HTTP 请求,正在等待回应... 200 OK
    7. 长度:1845094 (1.8M) [text/plain]
    8. 正在保存至: “openssh-9.4p1.tar.gz”
    9. openssh-9.4p1.tar.gz 100%[=========================================================================>] 1.76M 138KB/s 用时 16s
    10. 2023-09-11 04:04:22 (114 KB/s) - 已保存 “openssh-9.4p1.tar.gz” [1845094/1845094])
    11. [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
    12. --2023-09-11 04:04:24-- 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
    13. 正在解析主机 src.fedoraproject.org (src.fedoraproject.org)... 38.145.60.20, 38.145.60.21
    14. 正在连接 src.fedoraproject.org (src.fedoraproject.org)|38.145.60.20|:443... 已连接。
    15. 已发出 HTTP 请求,正在等待回应... 200 OK
    16. 长度:29229 (29K) [application/x-gzip]
    17. 正在保存至: “x11-ssh-askpass-1.2.4.1.tar.gz”
    18. x11-ssh-askpass-1.2.4.1.tar.gz 100%[=========================================================================>] 28.54K 115KB/s 用时 0.2s
    19. 2023-09-11 04:04:26 (115 KB/s) - 已保存 “x11-ssh-askpass-1.2.4.1.tar.gz” [29229/29229])
    20. [root@localhost SOURCES]# cp /etc/pam.d/sshd sshd.pam.el8
    21. [root@localhost SOURCES]# ll
    22. 总用量 11504
    23. -rw-r--r--. 1 root root 1845094 8月 9 23:15 openssh-9.4p1.tar.gz
    24. -rw-r--r--. 1 root root 727 9月 11 04:04 sshd.pam.el8
    25. -rw-r--r--. 1 root root 29229 6月 25 2004 x11-ssh-askpass-1.2.4.1.tar.gz
    26. [root@localhost SOURCES]# cat sshd.pam.el8
    27. #%PAM-1.0
    28. auth substack password-auth
    29. auth include postlogin
    30. account required pam_sepermit.so
    31. account required pam_nologin.so
    32. account include password-auth
    33. password include password-auth
    34. # pam_selinux.so close should be the first session rule
    35. session required pam_selinux.so close
    36. session required pam_loginuid.so
    37. # pam_selinux.so open should only be followed by sessions to be executed in the user context
    38. session required pam_selinux.so open env_params
    39. session required pam_namespace.so
    40. session optional pam_keyinit.so force revoke
    41. session optional pam_motd.so
    42. session include password-auth
    43. session include postlogin

    6、 安装编译工具

    1. [root@localhost SOURCES]# cd ../SPECS
    2. [root@localhost SPECS]# dnf install rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel -y
    3. os 3.8 MB/s | 3.9 kB 00:00
    4. app 49 MB/s | 7.6 MB 00:00
    5. 依赖关系解决。
    6. =========================================================================================================================================================
    7. 软件包 架构 版本 仓库 大小
    8. =========================================================================================================================================================
    9. 安装:
    10. gcc x86_64 8.5.0-10.el8 app 23 M
    11. openssl-devel x86_64 1:1.1.1k-5.el8_5 os 2.3 M
    12. pam-devel x86_64 1.3.1-16.el8 os 210 k
    13. perl-devel x86_64 4:5.26.3-421.el8 app 599 k
    14. rpm-build x86_64 4.14.3-21.el8 app 174 k
    15. zlib-devel x86_64 1.2.11-17.el8 os 58 k
    16. ...
    17. 已安装:
    18. annobin-10.29-3.el8.x86_64 binutils-2.30-113.el8.x86_64
    19. bzip2-1.0.6-26.el8.x86_64 cpp-8.5.0-10.el8.x86_64
    20. dwz-0.12-10.el8.x86_64 efi-srpm-macros-3-3.el8.noarch
    21. elfutils-0.186-1.el8.x86_64 gc-7.6.4-3.el8.x86_64
    22. gcc-8.5.0-10.el8.x86_64 gdb-headless-8.2-18.el8.x86_64
    23. ghc-srpm-macros-1.4.2-7.el8.noarch glibc-devel-2.28-189.el8.x86_64
    24. glibc-headers-2.28-189.el8.x86_64 go-srpm-macros-2-17.el8.noarch
    25. guile-5:2.0.14-7.el8.x86_64 isl-0.16.1-6.el8.x86_64
    26. kernel-headers-4.18.0-365.el8.x86_64 keyutils-libs-devel-1.5.10-9.el8.x86_64
    27. krb5-devel-1.18.2-14.el8.x86_64 libatomic_ops-7.6.2-3.el8.x86_64
    28. libbabeltrace-1.5.4-3.el8.x86_64 libcom_err-devel-1.45.6-3.el8.x86_64
    29. libipt-1.6.1-8.el8.x86_64 libkadm5-1.18.2-14.el8.x86_64
    30. libmpc-1.1.0-9.1.el8.x86_64 libpkgconf-1.4.2-1.el8.x86_64
    31. libselinux-devel-2.9-5.el8.x86_64 libsepol-devel-2.9-3.el8.x86_64
    32. libverto-devel-0.3.0-5.el8.x86_64 libxcrypt-devel-4.1.1-6.el8.x86_64
    33. ocaml-srpm-macros-5-4.el8.noarch openblas-srpm-macros-2-2.el8.noarch
    34. openssl-devel-1:1.1.1k-5.el8_5.x86_64 pam-devel-1.3.1-16.el8.x86_64
    35. patch-2.7.6-11.el8.x86_64 pcre2-devel-10.32-2.el8.x86_64
    36. pcre2-utf16-10.32-2.el8.x86_64 pcre2-utf32-10.32-2.el8.x86_64
    37. perl-CPAN-Meta-2.150010-396.el8.noarch perl-CPAN-Meta-Requirements-2.140-396.el8.noarch
    38. perl-CPAN-Meta-YAML-0.018-397.el8.noarch perl-Carp-1.42-396.el8.noarch
    39. perl-Data-Dumper-2.167-399.el8.x86_64 perl-Digest-1.17-395.el8.noarch
    40. perl-Digest-MD5-2.55-396.el8.x86_64 perl-Encode-4:2.97-3.el8.x86_64
    41. perl-Encode-Locale-1.05-10.module_el8.3.0+416+dee7bcef.noarch perl-Errno-1.28-421.el8.x86_64
    42. perl-Exporter-5.72-396.el8.noarch perl-ExtUtils-Command-1:7.34-1.el8.noarch
    43. perl-ExtUtils-Install-2.14-4.el8.noarch perl-ExtUtils-MakeMaker-1:7.34-1.el8.noarch
    44. perl-ExtUtils-Manifest-1.70-395.el8.noarch perl-ExtUtils-ParseXS-1:3.35-2.el8.noarch
    45. perl-File-Path-2.15-2.el8.noarch perl-File-Temp-0.230.600-1.el8.noarch
    46. perl-Getopt-Long-1:2.50-4.el8.noarch perl-HTTP-Tiny-0.074-1.el8.noarch
    47. perl-IO-1.38-421.el8.x86_64 perl-IO-Socket-IP-0.39-5.el8.noarch
    48. perl-IO-Socket-SSL-2.066-4.module_el8.4.0+517+be1595ff.noarch perl-JSON-PP-1:2.97.001-3.el8.noarch
    49. perl-MIME-Base64-3.15-396.el8.x86_64 perl-Math-BigInt-1:1.9998.11-7.el8.noarch
    50. perl-Math-Complex-1.59-421.el8.noarch perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch
    51. perl-Net-SSLeay-1.88-1.module_el8.4.0+517+be1595ff.x86_64 perl-PathTools-3.74-1.el8.x86_64
    52. perl-Pod-Escapes-1:1.07-395.el8.noarch perl-Pod-Perldoc-3.28-396.el8.noarch
    53. perl-Pod-Simple-1:3.35-395.el8.noarch perl-Pod-Usage-4:1.69-395.el8.noarch
    54. perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 perl-Socket-4:2.027-3.el8.x86_64
    55. perl-Storable-1:3.11-3.el8.x86_64 perl-Term-ANSIColor-4.06-396.el8.noarch
    56. perl-Term-Cap-1.17-395.el8.noarch perl-Test-Harness-1:3.42-1.el8.noarch
    57. perl-Text-ParseWords-3.30-395.el8.noarch perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch
    58. perl-Time-HiRes-4:1.9758-2.el8.x86_64 perl-Time-Local-1:1.280-1.el8.noarch
    59. perl-URI-1.73-3.el8.noarch perl-Unicode-Normalize-1.25-396.el8.x86_64
    60. perl-constant-1.33-396.el8.noarch perl-devel-4:5.26.3-421.el8.x86_64
    61. perl-interpreter-4:5.26.3-421.el8.x86_64 perl-libnet-3.11-3.el8.noarch
    62. perl-libs-4:5.26.3-421.el8.x86_64 perl-macros-4:5.26.3-421.el8.x86_64
    63. perl-parent-1:0.237-1.el8.noarch perl-podlators-4.11-1.el8.noarch
    64. perl-srpm-macros-1-25.el8.noarch perl-threads-1:2.21-2.el8.x86_64
    65. perl-threads-shared-1.58-2.el8.x86_64 perl-version-6:0.99.24-1.el8.x86_64
    66. pkgconf-1.4.2-1.el8.x86_64 pkgconf-m4-1.4.2-1.el8.noarch
    67. pkgconf-pkg-config-1.4.2-1.el8.x86_64 python-rpm-macros-3-41.el8.noarch
    68. python-srpm-macros-3-41.el8.noarch python3-pyparsing-2.1.10-7.el8.noarch
    69. python3-rpm-macros-3-41.el8.noarch qt5-srpm-macros-5.15.2-1.el8.noarch
    70. redhat-rpm-config-127-1.el8.noarch rpm-build-4.14.3-21.el8.x86_64
    71. rust-srpm-macros-5-2.el8.noarch systemtap-sdt-devel-4.6-4.el8.x86_64
    72. unzip-6.0-46.el8.x86_64 zip-3.0-23.el8.x86_64
    73. zlib-devel-1.2.11-17.el8.x86_64 zstd-1.4.4-1.el8.x86_64
    74. 完毕!

    7、 生成源spec文件

    1. [root@localhost SPECS]# vi openssh.spec
    2. [root@localhost SPECS]# cat openssh.spec
    3. %global ver 9.4p1
    4. %global rel 1%{?dist}
    5. # OpenSSH privilege separation requires a user & group ID
    6. %global sshd_uid 74
    7. %global sshd_gid 74
    8. # Version of ssh-askpass
    9. %global aversion 1.2.4.1
    10. # Do we want to disable building of x11-askpass? (1=yes 0=no)
    11. %global no_x11_askpass 1
    12. # Do we want to disable building of gnome-askpass? (1=yes 0=no)
    13. %global no_gnome_askpass 1
    14. # Do we want to link against a static libcrypto? (1=yes 0=no)
    15. %global static_libcrypto 0
    16. # Do we want smartcard support (1=yes 0=no)
    17. %global scard 0
    18. # Use GTK2 instead of GNOME in gnome-ssh-askpass
    19. %global gtk2 1
    20. # Use build6x options for older RHEL builds
    21. # RHEL 7 not yet supported
    22. %if 0%{?rhel} > 6
    23. %global build6x 0
    24. %else
    25. %global build6x 1
    26. %endif
    27. %if 0%{?fedora} >= 26
    28. %global compat_openssl 1
    29. %else
    30. %global compat_openssl 0
    31. %endif
    32. # Do we want kerberos5 support (1=yes 0=no)
    33. %global kerberos5 1
    34. # Reserve options to override askpass settings with:
    35. # rpm -ba|--rebuild --define 'skip_xxx 1'
    36. %{?skip_x11_askpass:%global no_x11_askpass 1}
    37. %{?skip_gnome_askpass:%global no_gnome_askpass 1}
    38. # Add option to build without GTK2 for older platforms with only GTK+.
    39. # RedHat <= 7.2 and Red Hat Advanced Server 2.1 are examples.
    40. # rpm -ba|--rebuild --define 'no_gtk2 1'
    41. %{?no_gtk2:%global gtk2 0}
    42. # Is this a build for RHL 6.x or earlier?
    43. %{?build_6x:%global build6x 1}
    44. # If this is RHL 6.x, the default configuration has sysconfdir in /usr/etc.
    45. %if %{build6x}
    46. %global _sysconfdir /etc
    47. %endif
    48. # Options for static OpenSSL link:
    49. # rpm -ba|--rebuild --define "static_openssl 1"
    50. %{?static_openssl:%global static_libcrypto 1}
    51. # Options for Smartcard support: (needs libsectok and openssl-engine)
    52. # rpm -ba|--rebuild --define "smartcard 1"
    53. %{?smartcard:%global scard 1}
    54. # Is this a build for the rescue CD (without PAM)? (1=yes 0=no)
    55. %global rescue 0
    56. %{?build_rescue:%global rescue 1}
    57. # Turn off some stuff for resuce builds
    58. %if %{rescue}
    59. %global kerberos5 0
    60. %endif
    61. Summary: The OpenSSH implementation of SSH protocol version 2.
    62. Name: openssh
    63. Version: %{ver}
    64. %if %{rescue}
    65. Release: %{rel}rescue
    66. %else
    67. Release: %{rel}
    68. %endif
    69. URL: https://www.openssh.com/portable.html
    70. Source0: https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
    71. Source1: http://www.jmknoble.net/software/x11-ssh-askpass/x11-ssh-askpass-%{aversion}.tar.gz
    72. Source2: sshd.pam.el8
    73. License: BSD
    74. Group: Applications/Internet
    75. BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
    76. Obsoletes: ssh
    77. %if %{build6x}
    78. PreReq: initscripts >= 5.00
    79. %else
    80. Requires: initscripts >= 5.20
    81. %endif
    82. BuildRequires: perl
    83. %if %{compat_openssl}
    84. BuildRequires: compat-openssl10-devel
    85. %else
    86. BuildRequires: openssl-devel >= 1.0.1
    87. #BuildRequires: openssl-devel < 1.1
    88. %endif
    89. BuildRequires: /bin/login
    90. %if ! %{build6x}
    91. BuildRequires: glibc-devel, pam
    92. %else
    93. BuildRequires: /usr/include/security/pam_appl.h
    94. %endif
    95. %if ! %{no_x11_askpass}
    96. BuildRequires: /usr/include/X11/Xlib.h
    97. # Xt development tools
    98. BuildRequires: libXt-devel
    99. # Provides xmkmf
    100. BuildRequires: imake
    101. # Rely on relatively recent gtk
    102. BuildRequires: gtk2-devel
    103. %endif
    104. %if ! %{no_gnome_askpass}
    105. BuildRequires: pkgconfig
    106. %endif
    107. %if %{kerberos5}
    108. BuildRequires: krb5-devel
    109. BuildRequires: krb5-libs
    110. %endif
    111. %package clients
    112. Summary: OpenSSH clients.
    113. Requires: openssh = %{version}-%{release}
    114. Group: Applications/Internet
    115. Obsoletes: ssh-clients
    116. %package server
    117. Summary: The OpenSSH server daemon.
    118. Group: System Environment/Daemons
    119. Obsoletes: ssh-server
    120. Requires: openssh = %{version}-%{release}, chkconfig >= 0.9
    121. %if ! %{build6x}
    122. Requires: /etc/pam.d/system-auth
    123. %endif
    124. %package askpass
    125. Summary: A passphrase dialog for OpenSSH and X.
    126. Group: Applications/Internet
    127. Requires: openssh = %{version}-%{release}
    128. Obsoletes: ssh-extras
    129. %package askpass-gnome
    130. Summary: A passphrase dialog for OpenSSH, X, and GNOME.
    131. Group: Applications/Internet
    132. Requires: openssh = %{version}-%{release}
    133. Obsoletes: ssh-extras
    134. %description
    135. SSH (Secure SHell) is a program for logging into and executing
    136. commands on a remote machine. SSH is intended to replace rlogin and
    137. rsh, and to provide secure encrypted communications between two
    138. untrusted hosts over an insecure network. X11 connections and
    139. arbitrary TCP/IP ports can also be forwarded over the secure channel.
    140. OpenSSH is OpenBSD's version of the last free version of SSH, bringing
    141. it up to date in terms of security and features, as well as removing
    142. all patented algorithms to separate libraries.
    143. This package includes the core files necessary for both the OpenSSH
    144. client and server. To make this package useful, you should also
    145. install openssh-clients, openssh-server, or both.
    146. %description clients
    147. OpenSSH is a free version of SSH (Secure SHell), a program for logging
    148. into and executing commands on a remote machine. This package includes
    149. the clients necessary to make encrypted connections to SSH servers.
    150. You'll also need to install the openssh package on OpenSSH clients.
    151. %description server
    152. OpenSSH is a free version of SSH (Secure SHell), a program for logging
    153. into and executing commands on a remote machine. This package contains
    154. the secure shell daemon (sshd). The sshd daemon allows SSH clients to
    155. securely connect to your SSH server. You also need to have the openssh
    156. package installed.
    157. %description askpass
    158. OpenSSH is a free version of SSH (Secure SHell), a program for logging
    159. into and executing commands on a remote machine. This package contains
    160. an X11 passphrase dialog for OpenSSH.
    161. %description askpass-gnome
    162. OpenSSH is a free version of SSH (Secure SHell), a program for logging
    163. into and executing commands on a remote machine. This package contains
    164. an X11 passphrase dialog for OpenSSH and the GNOME GUI desktop
    165. environment.
    166. %prep
    167. %if ! %{no_x11_askpass}
    168. %setup -q -a 1
    169. %else
    170. %setup -q
    171. %endif
    172. %build
    173. %if %{rescue}
    174. CFLAGS="$RPM_OPT_FLAGS -Os"; export CFLAGS
    175. %endif
    176. %configure \
    177. --sysconfdir=%{_sysconfdir}/ssh \
    178. --libexecdir=%{_libexecdir}/openssh \
    179. --datadir=%{_datadir}/openssh \
    180. --with-default-path=/usr/local/bin:/bin:/usr/bin \
    181. --with-superuser-path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \
    182. --with-privsep-path=%{_var}/empty/sshd \
    183. --mandir=%{_mandir} \
    184. --with-mantype=man \
    185. --disable-strip \
    186. %if %{scard}
    187. --with-smartcard \
    188. %endif
    189. %if %{rescue}
    190. --without-pam \
    191. %else
    192. --with-pam \
    193. %endif
    194. %if %{kerberos5}
    195. --with-kerberos5=$K5DIR \
    196. %endif
    197. %if %{static_libcrypto}
    198. perl -pi -e "s|-lcrypto|%{_libdir}/libcrypto.a|g" Makefile
    199. %endif
    200. make
    201. %if ! %{no_x11_askpass}
    202. pushd x11-ssh-askpass-%{aversion}
    203. %configure --libexecdir=%{_libexecdir}/openssh
    204. xmkmf -a
    205. make
    206. popd
    207. %endif
    208. # Define a variable to toggle gnome1/gtk2 building. This is necessary
    209. # because RPM doesn't handle nested %if statements.
    210. %if %{gtk2}
    211. gtk2=yes
    212. %else
    213. gtk2=no
    214. %endif
    215. %if ! %{no_gnome_askpass}
    216. pushd contrib
    217. if [ $gtk2 = yes ] ; then
    218. make gnome-ssh-askpass2
    219. mv gnome-ssh-askpass2 gnome-ssh-askpass
    220. else
    221. make gnome-ssh-askpass1
    222. mv gnome-ssh-askpass1 gnome-ssh-askpass
    223. fi
    224. popd
    225. %endif
    226. %install
    227. rm -rf $RPM_BUILD_ROOT
    228. mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/ssh
    229. mkdir -p -m755 $RPM_BUILD_ROOT%{_libexecdir}/openssh
    230. mkdir -p -m755 $RPM_BUILD_ROOT%{_var}/empty/sshd
    231. make install DESTDIR=$RPM_BUILD_ROOT
    232. install -d $RPM_BUILD_ROOT/etc/pam.d/
    233. install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
    234. install -d $RPM_BUILD_ROOT%{_libexecdir}/openssh
    235. %if %{build6x}
    236. install -m644 contrib/redhat/sshd.pam.old $RPM_BUILD_ROOT/etc/pam.d/sshd
    237. %else
    238. install -m644 %{SOURCE2} $RPM_BUILD_ROOT/etc/pam.d/sshd
    239. install -m755 contrib/ssh-copy-id $RPM_BUILD_ROOT/usr/bin/ssh-copy-id
    240. %endif
    241. install -m755 contrib/redhat/sshd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/sshd
    242. %if ! %{no_x11_askpass}
    243. install x11-ssh-askpass-%{aversion}/x11-ssh-askpass $RPM_BUILD_ROOT%{_libexecdir}/openssh/x11-ssh-askpass
    244. ln -s x11-ssh-askpass $RPM_BUILD_ROOT%{_libexecdir}/openssh/ssh-askpass
    245. %endif
    246. %if ! %{no_gnome_askpass}
    247. install contrib/gnome-ssh-askpass $RPM_BUILD_ROOT%{_libexecdir}/openssh/gnome-ssh-askpass
    248. %endif
    249. %if ! %{scard}
    250. rm -f $RPM_BUILD_ROOT/usr/share/openssh/Ssh.bin
    251. %endif
    252. %if ! %{no_gnome_askpass}
    253. install -m 755 -d $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/
    254. install -m 755 contrib/redhat/gnome-ssh-askpass.csh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/
    255. install -m 755 contrib/redhat/gnome-ssh-askpass.sh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/
    256. %endif
    257. perl -pi -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT%{_mandir}/man*/*
    258. %clean
    259. rm -rf $RPM_BUILD_ROOT
    260. %triggerun server -- ssh-server
    261. if [ "$1" != 0 -a -r /var/run/sshd.pid ] ; then
    262. touch /var/run/sshd.restart
    263. fi
    264. %triggerun server -- openssh-server < 2.5.0p1
    265. # Count the number of HostKey and HostDsaKey statements we have.
    266. gawk 'BEGIN {IGNORECASE=1}
    267. /^hostkey/ || /^hostdsakey/ {sawhostkey = sawhostkey + 1}
    268. END {exit sawhostkey}' /etc/ssh/sshd_config
    269. # And if we only found one, we know the client was relying on the old default
    270. # behavior, which loaded the the SSH2 DSA host key when HostDsaKey wasn't
    271. # specified. Now that HostKey is used for both SSH1 and SSH2 keys, specifying
    272. # one nullifies the default, which would have loaded both.
    273. if [ $? -eq 1 ] ; then
    274. echo HostKey /etc/ssh/ssh_host_rsa_key >> /etc/ssh/sshd_config
    275. echo HostKey /etc/ssh/ssh_host_dsa_key >> /etc/ssh/sshd_config
    276. fi
    277. %triggerpostun server -- ssh-server
    278. if [ "$1" != 0 ] ; then
    279. /sbin/chkconfig --add sshd
    280. if test -f /var/run/sshd.restart ; then
    281. rm -f /var/run/sshd.restart
    282. /sbin/service sshd start > /dev/null 2>&1 || :
    283. fi
    284. fi
    285. %pre server
    286. %{_sbindir}/groupadd -r -g %{sshd_gid} sshd 2>/dev/null || :
    287. %{_sbindir}/useradd -d /var/empty/sshd -s /bin/false -u %{sshd_uid} \
    288. -g sshd -M -r sshd 2>/dev/null || :
    289. %post server
    290. /sbin/chkconfig --add sshd
    291. sed -i -e "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
    292. sed -i -e "s/#UsePAM no/UsePAM yes/g" /etc/ssh/sshd_config
    293. echo "KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1" >>/etc/ssh/sshd_config
    294. chmod 600 /etc/ssh/ssh_*_key
    295. %postun server
    296. /sbin/service sshd condrestart > /dev/null 2>&1 || :
    297. %preun server
    298. if [ "$1" = 0 ]
    299. then
    300. /sbin/service sshd stop > /dev/null 2>&1 || :
    301. /sbin/chkconfig --del sshd
    302. fi
    303. %files
    304. %defattr(-,root,root)
    305. %doc CREDITS ChangeLog INSTALL LICENCE OVERVIEW README* PROTOCOL* TODO
    306. %attr(0755,root,root) %{_bindir}/scp
    307. %attr(0644,root,root) %{_mandir}/man1/scp.1*
    308. %attr(0755,root,root) %dir %{_sysconfdir}/ssh
    309. %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/ssh/moduli
    310. %if ! %{rescue}
    311. %attr(0755,root,root) %{_bindir}/ssh-keygen
    312. %attr(0755,root,root) %{_bindir}/ssh-copy-id
    313. %attr(0644,root,root) %{_mandir}/man1/ssh-keygen.1*
    314. %attr(0755,root,root) %dir %{_libexecdir}/openssh
    315. %attr(4711,root,root) %{_libexecdir}/openssh/ssh-keysign
    316. %attr(0755,root,root) %{_libexecdir}/openssh/ssh-pkcs11-helper
    317. %attr(0755,root,root) %{_libexecdir}/openssh/ssh-sk-helper
    318. %attr(0644,root,root) %{_mandir}/man8/ssh-keysign.8*
    319. %attr(0644,root,root) %{_mandir}/man8/ssh-pkcs11-helper.8*
    320. %attr(0644,root,root) %{_mandir}/man8/ssh-sk-helper.8*
    321. %endif
    322. %if %{scard}
    323. %attr(0755,root,root) %dir %{_datadir}/openssh
    324. %attr(0644,root,root) %{_datadir}/openssh/Ssh.bin
    325. %endif
    326. %files clients
    327. %defattr(-,root,root)
    328. %attr(0755,root,root) %{_bindir}/ssh
    329. %attr(0644,root,root) %{_mandir}/man1/ssh.1*
    330. %attr(0644,root,root) %{_mandir}/man5/ssh_config.5*
    331. %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/ssh/ssh_config
    332. %if ! %{rescue}
    333. %attr(2755,root,nobody) %{_bindir}/ssh-agent
    334. %attr(0755,root,root) %{_bindir}/ssh-add
    335. %attr(0755,root,root) %{_bindir}/ssh-keyscan
    336. %attr(0755,root,root) %{_bindir}/sftp
    337. %attr(0644,root,root) %{_mandir}/man1/ssh-agent.1*
    338. %attr(0644,root,root) %{_mandir}/man1/ssh-add.1*
    339. %attr(0644,root,root) %{_mandir}/man1/ssh-keyscan.1*
    340. %attr(0644,root,root) %{_mandir}/man1/sftp.1*
    341. %endif
    342. %if ! %{rescue}
    343. %files server
    344. %defattr(-,root,root)
    345. %dir %attr(0111,root,root) %{_var}/empty/sshd
    346. %attr(0755,root,root) %{_sbindir}/sshd
    347. %attr(0755,root,root) %{_libexecdir}/openssh/sftp-server
    348. %attr(0644,root,root) %{_mandir}/man8/sshd.8*
    349. %attr(0644,root,root) %{_mandir}/man5/moduli.5*
    350. %attr(0644,root,root) %{_mandir}/man5/sshd_config.5*
    351. %attr(0644,root,root) %{_mandir}/man8/sftp-server.8*
    352. %attr(0755,root,root) %dir %{_sysconfdir}/ssh
    353. %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/ssh/sshd_config
    354. %attr(0600,root,root) %config(noreplace) /etc/pam.d/sshd
    355. %attr(0755,root,root) %config /etc/rc.d/init.d/sshd
    356. %endif
    357. %if ! %{no_x11_askpass}
    358. %files askpass
    359. %defattr(-,root,root)
    360. %doc x11-ssh-askpass-%{aversion}/README
    361. %doc x11-ssh-askpass-%{aversion}/ChangeLog
    362. %doc x11-ssh-askpass-%{aversion}/SshAskpass*.ad
    363. %{_libexecdir}/openssh/ssh-askpass
    364. %attr(0755,root,root) %{_libexecdir}/openssh/x11-ssh-askpass
    365. %endif
    366. %if ! %{no_gnome_askpass}
    367. %files askpass-gnome
    368. %defattr(-,root,root)
    369. %attr(0755,root,root) %config %{_sysconfdir}/profile.d/gnome-ssh-askpass.*
    370. %attr(0755,root,root) %{_libexecdir}/openssh/gnome-ssh-askpass
    371. %endif
    372. [root@localhost SPECS]# tree ..
    373. ..
    374. ├── SOURCES
    375. │   ├── openssh-9.4p1.tar.gz
    376. │   ├── sshd.pam.el8
    377. │   └── x11-ssh-askpass-1.2.4.1.tar.gz
    378. └── SPECS
    379. └── openssh.spec
    380. 2 directories, 4 files

    二、编译

    1、编译

    1. [root@localhost SPECS]# rpmbuild -bb openssh.spec
    2. 警告:展开行 113 注释中的宏:%{compat_openssl}
    3. 错误:构建依赖失败:
    4. perl 被 openssh-9.4p1-.el8.x86_64 需要
    5. [root@localhost SPECS]# dnf install perl
    6. 上次元数据过期检查:0:04:29 前,执行于 2023年09月11日 星期一 04时17分36秒。
    7. 依赖关系解决。
    8. =========================================================================================================================================================
    9. 软件包 架构 版本 仓库 大小
    10. =========================================================================================================================================================
    11. 安装:
    12. perl x86_64 4:5.26.3-421.el8 app 73 k
    13. 安装依赖关系:
    14. make x86_64 1:4.2.1-
    15. ...
    16. 已安装:
    17. make-1:4.2.1-11.el8.x86_64 perl-4:5.26.3-421.el8.x86_64
    18. perl-Algorithm-Diff-1.1903-9.el8.noarch perl-Archive-Tar-2.30-1.el8.noarch
    19. perl-Archive-Zip-1.60-3.el8.noarch perl-Attribute-Handlers-0.99-421.el8.noarch
    20. perl-B-Debug-1.26-2.el8.noarch perl-CPAN-2.18-397.el8.noarch
    21. perl-Compress-Bzip2-2.26-6.el8.x86_64 perl-Compress-Raw-Bzip2-2.081-1.el8.x86_64
    22. perl-Compress-Raw-Zlib-2.081-1.el8.x86_64 perl-Config-Perl-V-0.30-1.el8.noarch
    23. perl-DB_File-1.842-1.el8.x86_64 perl-Data-OptList-0.110-6.el8.noarch
    24. perl-Data-Section-0.200007-3.el8.noarch perl-Devel-PPPort-3.36-5.el8.x86_64
    25. perl-Devel-Peek-1.26-421.el8.x86_64 perl-Devel-SelfStubber-1.06-421.el8.noarch
    26. perl-Devel-Size-0.81-2.el8.x86_64 perl-Digest-SHA-1:6.02-1.el8.x86_64
    27. perl-Encode-devel-4:2.97-3.el8.x86_64 perl-Env-1.04-395.el8.noarch
    28. perl-ExtUtils-CBuilder-1:0.280230-2.el8.noarch perl-ExtUtils-Embed-1.34-421.el8.noarch
    29. perl-ExtUtils-MM-Utils-1:7.34-1.el8.noarch perl-ExtUtils-Miniperl-1.06-421.el8.noarch
    30. perl-File-Fetch-0.56-2.el8.noarch perl-File-HomeDir-1.002-4.el8.noarch
    31. perl-File-Which-1.22-2.el8.noarch perl-Filter-2:1.58-2.el8.x86_64
    32. perl-Filter-Simple-0.94-2.el8.noarch perl-IO-Compress-2.081-1.el8.noarch
    33. perl-IO-Zlib-1:1.10-421.el8.noarch perl-IPC-Cmd-2:1.02-1.el8.noarch
    34. perl-IPC-SysV-2.07-397.el8.x86_64 perl-IPC-System-Simple-1.25-17.el8.noarch
    35. perl-Locale-Codes-3.57-1.el8.noarch perl-Locale-Maketext-1.28-396.el8.noarch
    36. perl-Locale-Maketext-Simple-1:0.21-421.el8.noarch perl-MRO-Compat-0.13-4.el8.noarch
    37. perl-Math-BigInt-FastCalc-0.500.600-6.el8.x86_64 perl-Math-BigRat-0.2614-1.el8.noarch
    38. perl-Memoize-1.03-421.el8.noarch perl-Module-Build-2:0.42.24-5.el8.noarch
    39. perl-Module-CoreList-1:5.20181130-1.el8.noarch perl-Module-CoreList-tools-1:5.20181130-1.el8.noarch
    40. perl-Module-Load-1:0.32-395.el8.noarch perl-Module-Load-Conditional-0.68-395.el8.noarch
    41. perl-Module-Loaded-1:0.08-421.el8.noarch perl-Module-Metadata-1.000033-395.el8.noarch
    42. perl-Net-Ping-2.55-421.el8.noarch perl-Package-Generator-1.106-11.el8.noarch
    43. perl-Params-Check-1:0.38-395.el8.noarch perl-Params-Util-1.07-22.el8.x86_64
    44. perl-Perl-OSType-1.010-396.el8.noarch perl-PerlIO-via-QuotedPrint-0.08-395.el8.noarch
    45. perl-Pod-Checker-4:1.73-395.el8.noarch perl-Pod-Html-1.22.02-421.el8.noarch
    46. perl-Pod-Parser-1.63-396.el8.noarch perl-SelfLoader-1.23-421.el8.noarch
    47. perl-Software-License-0.103013-2.el8.noarch perl-Sub-Exporter-0.987-15.el8.noarch
    48. perl-Sub-Install-0.928-14.el8.noarch perl-Sys-Syslog-0.35-397.el8.x86_64
    49. perl-TermReadKey-2.37-7.el8.x86_64 perl-Test-1.30-421.el8.noarch
    50. perl-Test-Simple-1:1.302135-1.el8.noarch perl-Text-Balanced-2.03-395.el8.noarch
    51. perl-Text-Diff-1.45-2.el8.noarch perl-Text-Glob-0.11-4.el8.noarch
    52. perl-Text-Template-1.51-1.el8.noarch perl-Thread-Queue-3.13-1.el8.noarch
    53. perl-Time-Piece-1.31-421.el8.x86_64 perl-Unicode-Collate-1.25-2.el8.x86_64
    54. perl-autodie-2.29-396.el8.noarch perl-bignum-0.49-2.el8.noarch
    55. perl-encoding-4:2.22-3.el8.x86_64 perl-experimental-0.019-2.el8.noarch
    56. perl-inc-latest-2:0.500-9.el8.noarch perl-libnetcfg-4:5.26.3-421.el8.noarch
    57. perl-local-lib-2.000024-2.el8.noarch perl-open-1.11-421.el8.noarch
    58. perl-perlfaq-5.20180605-1.el8.noarch perl-utils-5.26.3-421.el8.noarch
    59. 完毕!
    60. [root@localhost SPECS]# rpmbuild -bb openssh.spec
    61. 正在执行(%prep):/bin/sh -e /var/tmp/rpm-tmp.01StAO
    62. + umask 022
    63. + cd /root/rpmbuild/BUILD
    64. + cd /root/rpmbuild/BUILD
    65. + rm -rf openssh-9.4p1
    66. + /usr/bin/gzip -dc /root/rpmbuild/SOURCES/openssh-9.4p1.tar.gz
    67. + /usr/bin/tar -xof -
    68. + STATUS=0
    69. + '[' 0 -ne 0 ']'
    70. + cd openssh-9.4p1
    71. + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
    72. + exit 0
    73. 正在执行(%build):/bin/sh -e /var/tmp/rpm-tmp.3OTjIN
    74. + umask 022
    75. + cd /root/rpmbuild/BUILD
    76. + cd openssh-9.4p1
    77. ...
    78. Recommends: openssh-debugsource(x86-64) = 9.4p1-1.el8
    79. 检查未打包文件:/usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/openssh-9.4p1-1.el8.x86_64
    80. 已写至:/root/rpmbuild/RPMS/x86_64/openssh-9.4p1-1.el8.x86_64.rpm
    81. 已写至:/root/rpmbuild/RPMS/x86_64/openssh-clients-9.4p1-1.el8.x86_64.rpm
    82. 已写至:/root/rpmbuild/RPMS/x86_64/openssh-server-9.4p1-1.el8.x86_64.rpm
    83. 已写至:/root/rpmbuild/RPMS/x86_64/openssh-debugsource-9.4p1-1.el8.x86_64.rpm
    84. 已写至:/root/rpmbuild/RPMS/x86_64/openssh-debuginfo-9.4p1-1.el8.x86_64.rpm
    85. 已写至:/root/rpmbuild/RPMS/x86_64/openssh-clients-debuginfo-9.4p1-1.el8.x86_64.rpm
    86. 已写至:/root/rpmbuild/RPMS/x86_64/openssh-server-debuginfo-9.4p1-1.el8.x86_64.rpm
    87. 正在执行(%clean):/bin/sh -e /var/tmp/rpm-tmp.umYllQ
    88. + umask 022
    89. + cd /root/rpmbuild/BUILD
    90. + cd openssh-9.4p1
    91. + rm -rf /root/rpmbuild/BUILDROOT/openssh-9.4p1-1.el8.x86_64
    92. + exit 0

    看到“+ exit 0”表示编译成功。

    三、测试验证

    1、安装新编译的openssh RPM包

    1. [root@localhost SPECS]# cd /root/rpmbuild/RPMS/x86_64/
    2. [root@localhost SPECS]# cd /root/rpmbuild/RPMS/x86_64
    3. [root@localhost x86_64]# dnf update *
    4. 上次元数据过期检查:1:26:58 前,执行于 2023年09月11日 星期一 04时17分36秒。
    5. 软件包 openssh-clients-debuginfo 未安装,无法更新。
    6. 未找到匹配的参数: openssh-clients-debuginfo-9.4p1-1.el8.x86_64.rpm
    7. 软件包 openssh-debuginfo 未安装,无法更新。
    8. 未找到匹配的参数: openssh-debuginfo-9.4p1-1.el8.x86_64.rpm
    9. 软件包 openssh-debugsource 未安装,无法更新。
    10. 未找到匹配的参数: openssh-debugsource-9.4p1-1.el8.x86_64.rpm
    11. 软件包 openssh-server-debuginfo 未安装,无法更新。
    12. 未找到匹配的参数: openssh-server-debuginfo-9.4p1-1.el8.x86_64.rpm
    13. 依赖关系解决。
    14. =========================================================================================================================================================
    15. 软件包 架构 版本 仓库 大小
    16. =========================================================================================================================================================
    17. 升级:
    18. openssh x86_64 9.4p1-1.el8 @commandline 680 k
    19. openssh-clients x86_64 9.4p1-1.el8 @commandline 644 k
    20. openssh-server x86_64 9.4p1-1.el8 @commandline 469 k
    21. 事务概要
    22. =========================================================================================================================================================
    23. 升级 3 软件包
    24. 总计:1.8 M
    25. 确定吗?[y/N]: y
    26. 下载软件包:
    27. 运行事务检查
    28. 事务检查成功。
    29. 运行事务测试
    30. 事务测试成功。
    31. 运行事务
    32. 准备中 : 1/1
    33. 运行脚本: openssh-9.4p1-1.el8.x86_64 1/1
    34. 升级 : openssh-9.4p1-1.el8.x86_64 1/6
    35. 升级 : openssh-clients-9.4p1-1.el8.x86_64 2/6
    36. 运行脚本: openssh-server-9.4p1-1.el8.x86_64 3/6
    37. 升级 : openssh-server-9.4p1-1.el8.x86_64 3/6
    38. 运行脚本: openssh-server-9.4p1-1.el8.x86_64 3/6
    39. 运行脚本: openssh-server-8.0p1-12.el8.x86_64 4/6
    40. 清理 : openssh-server-8.0p1-12.el8.x86_64 4/6
    41. 运行脚本: openssh-server-8.0p1-12.el8.x86_64 4/6
    42. 清理 : openssh-clients-8.0p1-12.el8.x86_64 5/6
    43. 清理 : openssh-8.0p1-12.el8.x86_64 6/6
    44. 运行脚本: openssh-8.0p1-12.el8.x86_64 6/6
    45. 验证 : openssh-9.4p1-1.el8.x86_64 1/6
    46. 验证 : openssh-8.0p1-12.el8.x86_64 2/6
    47. 验证 : openssh-clients-9.4p1-1.el8.x86_64 3/6
    48. 验证 : openssh-clients-8.0p1-12.el8.x86_64 4/6
    49. 验证 : openssh-server-9.4p1-1.el8.x86_64 5/6
    50. 验证 : openssh-server-8.0p1-12.el8.x86_64 6/6
    51. 已升级:
    52. openssh-9.4p1-1.el8.x86_64 openssh-clients-9.4p1-1.el8.x86_64 openssh-server-9.4p1-1.el8.x86_64
    53. 完毕!
    54. [root@localhost x86_64]# systemctl restart sshd
    55. [root@localhost x86_64]# systemctl status sshd
    56. ● sshd.service - SYSV: OpenSSH server daemon
    57. Loaded: loaded (/etc/rc.d/init.d/sshd; generated)
    58. Active: active (running) since Mon 2023-09-11 05:44:45 EDT; 7s ago
    59. Docs: man:systemd-sysv-generator(8)
    60. Process: 111506 ExecStart=/etc/rc.d/init.d/sshd start (code=exited, status=0/SUCCESS)
    61. Main PID: 111516 (sshd)
    62. Tasks: 1 (limit: 24686)
    63. Memory: 924.0K
    64. CGroup: /system.slice/sshd.service
    65. └─111516 sshd: /usr/sbin/sshd [listener] 0 of 10-100 startups
    66. 9月 11 05:44:45 localhost.localdomain systemd[1]: Starting SYSV: OpenSSH server daemon...
    67. 9月 11 05:44:45 localhost.localdomain sshd[111513]: /sbin/restorecon: lstat(/etc/ssh/ssh_host_dsa_key.pub) failed: No such file or directory
    68. 9月 11 05:44:45 localhost.localdomain sshd[111516]: Server listening on 0.0.0.0 port 22.
    69. 9月 11 05:44:45 localhost.localdomain sshd[111516]: Server listening on :: port 22.
    70. 9月 11 05:44:45 localhost.localdomain sshd[111506]: Starting sshd:[ 确定 ]
    71. 9月 11 05:44:45 localhost.localdomain systemd[1]: Started SYSV: OpenSSH server daemon.

    2、版本验证:

    1. Last login: Mon Sep 11 05:45:02 2023 from 192.168.80.1
    2. [root@localhost ~]# ssh -V
    3. OpenSSH_9.4p1, OpenSSL 1.1.1k FIPS 25 Mar 2021
    4. [root@localhost ~]# sshd -V
    5. OpenSSH_9.4, OpenSSL 1.1.1k FIPS 25 Mar 2021
    6. [root@localhost ~]# rpm -qa |grep openssh
    7. openssh-9.4p1-1.el8.x86_64
    8. openssh-server-9.4p1-1.el8.x86_64
    9. openssh-clients-9.4p1-1.el8.x86_64
    10. [root@localhost ~]#

     

    可以将/root/rpmbuild/RPMS/x86_64下的软件包进行拷贝分发或放到http服务器共享。至此,rpm包制作完成。

    3、注意事项

    openssh升级到9.*后加密算法最低要求256位,因此升级openssh后低版本的客户端和CRT都将无法连接,报以下错误:

    Key exchange failed.
    No compatible key-exchange method. The server supports these methods: sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256

    此时其它未升级openssh的centos6服务器都连不上更新服务器的,不要以为升级失败了,只需将需要连接本服务器的主机的openssh-client也升级了即可。

    Windows连接请升级SecureCRT到8.*.*版本,同时会话属性中仅启用256或512位算法,即可正常连接。

    可以看到连接是没有任何问题的。

     本人编译的成品包下载地址:openssh9.4p1 for el8

  • 相关阅读:
    LabVIEW通信-CAN
    Redis技术
    jedis实现分布式锁案例:
    修改huggingface的缓存路径
    HEVC参考帧技术
    vue多级路由,实现前台,后台,登录注册界面同级
    DXF读写:标注样式组码中文说明
    Salesforce-Visualforce-1.概要(Get Started with Visualforce)
    python+django车辆违章信息查询管理系统pycharm项目
    javascript 赋值运算符、一元运算符、运算优先级详细解析与代码实例
  • 原文地址:https://blog.csdn.net/forestqq/article/details/132800035