编译环境:OL7.9
    1.查询当前软件版本:
    1657349367911.png
    2.创建用户:
    1657349515436.png
    3.备份ssh:
    1657349743904.png
    配置阿里云镜像:

    1. yum install wget
    2. wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    3. yum makecache

    4.安装rpm-build及编译环境:

    1. #安装rpm-build包及其他编译需要的包
    2. yum install rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel unzip
    3. mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

    5.下载Openssl:
    地址:https://github.com/openssl/openssl/tags
    版本选择:1.1.1q.tar.gz
    将文件上传到/home/test文件夹下

    1. cd /home/test
    2. su test
    3. #解压文件,并从新打包,因为后面的rpm打包工具目录名问题
    4. tar -zxvf openssl-OpenSSL_1_1_1q.tar.gz
    5. #解压得到的文件夹名称openssl-OpenSSL_1_1_1q改为openssl-1.1.1q
    6. mv openssl-OpenSSL_1_1_1q openssl-1.1.1q
    7. #打包文件夹
    8. tar cvf openssl-1.1.1q.tar.gz openssl-1.1.1q
    9. #将openssl-1.1.1q.tar.gz复制到/root/
    10. cp /home/test/openssl-1.1.1q.tar.gz /root/rpmbuild/SOURCES/

    编写openssl.spec文件

    1. cd /root/rpmbuild/SPECS
    2. vi openssl.spec
    3. #-----文件内容,请使用vi创建该文件
    4. Summary: OpenSSL 1.1.1q for OLE
    5. Name: openssl
    6. Version: %{?version}%{!?version:1.1.1q}
    7. Release: 1%{?dist}
    8. Obsoletes: %{name} <= %{version}
    9. Provides: %{name} = %{version}
    10. URL: https://www.openssl.org/
    11. License: GPLv2+
    12. Source: https://www.openssl.org/source/%{name}-%{version}.tar.gz
    13. BuildRequires: make gcc perl perl-WWW-Curl
    14. BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
    15. %global openssldir /usr/openssl
    16. %description
    17. OpenSSL RPM for version 1.1.1q on OLE
    18. %package devel
    19. Summary: Development files for programs which will use the openssl library
    20. Group: Development/Libraries
    21. Requires: %{name} = %{version}-%{release}
    22. %description devel
    23. OpenSSL RPM for version 1.1.1q on Centos (development package)
    24. %prep
    25. %setup -q
    26. %build
    27. ./config --prefix=%{openssldir} --openssldir=%{openssldir}
    28. make
    29. %install
    30. [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
    31. %make_install
    32. mkdir -p %{buildroot}%{_bindir}
    33. mkdir -p %{buildroot}%{_libdir}
    34. ln -sf %{openssldir}/lib/libssl.so.1.1 %{buildroot}%{_libdir}
    35. ln -sf %{openssldir}/lib/libcrypto.so.1.1 %{buildroot}%{_libdir}
    36. ln -sf %{openssldir}/bin/openssl %{buildroot}%{_bindir}
    37. %clean
    38. [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
    39. %files
    40. %{openssldir}
    41. %defattr(-,root,root)
    42. /usr/bin/openssl
    43. /usr/lib64/libcrypto.so.1.1
    44. /usr/lib64/libssl.so.1.1
    45. %files devel
    46. %{openssldir}/include/*
    47. %defattr(-,root,root)
    48. %post -p /sbin/ldconfig

    执行编译打包:

    1. rpmbuild -D "version 1.1.1q" -bb openssl.spec
    2. #报缺少perl-WWW-curl
    3. cd /home/test
    4. rpm -ivh perl-WWW-Curl-4.15-13.el7.x86_64.rpm
    5. cd /root/rpmbuild/SPECS

    安装openssl-1.1.1q:

    1. cd /root/rpmbuild/RPMS/x86_64
    2. rpm -Uvh --nodeps --force openssl*.rpm
    3. openssl version -a

    下载OpenSSH9.0p1

    1. cd /root/rpmbuild/SOURCES
    2. wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.0p1.tar.gz

    1657353344772.png
    提取openssh.spec文件

    1. tar -zxvf openssh-9.0p1.tar.gz openssh-9.0p1/contrib/redhat/openssh.spec
    2. mv openssh-9.0p1/contrib/redhat/openssh.spec /root/rpmbuild/SPECS
    3. cd /root/rpmbuild/SPECS
    4. rpmbuild -bb openssh.spec

    1657353604078.png
    添加插件:

    1. cd /root/rpmbuild/SOURCES
    2. 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
    3. cd /root/rpmbuild/SPECS
    4. rpmbuild -bb openssh.spec

    1657353736787.png
    安装其他依赖:

    1. yum install gtk2-devel
    2. yum install imake
    3. yum install libXt-devel

    参考链接:
    https://www.ngui.cc/51cto/show-530991.html
    https://blog.51cto.com/onlyoulinux/2585471?ivk_sa=1024320u

    1. #查看系统ssh版本
    2. ssh -V
    3. #查看系统openssl版本
    4. openssl version -a
    5. #切换用户root
    6. su root
    7. #创建用户及密码test/Test123
    8. useradd test
    9. userpwd test
    10. #备份ssh文件,系统默认7.4p1版本
    11. cp -r /etc/ssh/ /etc/ssh-old-20220709
    12. #备份pam下的sshd文件
    13. cp /etc/pam.d/sshd /etc/pam.d/sshd-old-20220709