当前位置:   article > 正文

CentOS 5/6/7 基于开源项目制作openssh 9.6p1 rpm包—— 筑梦之路_centos6 openssh9.6rpm

centos6 openssh9.6rpm

背景介绍

开源项目地址:https://github.com/boypt/openssh-rpms.git

该项目主要支持了centos 5 、6、7版本,针对使用了比较老的操作系统进行openssh安全加固,还是不错的项目,使用简单、一件制作,欢迎大家去支持作者。这里我来使用试试,并将过程进行记录。

环境说明

操作系统:CentOS Linux release 7.3.1611 (Core)

CPU架构:x86

内核版本:3.10.0-514.26.2.el7.x86_64

准备工作

1. 准备源码

  1. # 准备源码
  2. wget --no-check-certificate https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz
  3. wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1w.tar.gz
  4. git clone https://github.com/boypt/openssh-rpms.git
  5. # 将源码下载放到downloads目录下

2. 准备编译打包环境

  1. yum groupinstall -y "Development Tools"
  2. yum install -y imake rpm-build pam-devel krb5-devel zlib-devel libXt-devel libX11-devel gtk2-devel

3. 修改开源脚本

  1. # 修改脚本pullsrc.sh
  2. # 第一处
  3. source version.env
  4. 改为
  5. source ./version.env
  6. # 第二处
  7. wget OPENSSLSRC
  8. wget OPENSSHSRC
  9. wget ASKPASSSRC
  10. 改为
  11. wget --no-check-certificate $OPENSSLMIR/$OPENSSLSRC
  12. wget --no-check-certificate $OPENSSHMIR/$OPENSSHSRC
  13. wget --no-check-certificate $ASKPASSMIR/$ASKPASSSRC
  14. 修改脚本compile.sh
  15. source version.env
  16. 改为
  17. source ./version.env
  1. # 添加ssh-copy-id命令
  2. cd el7/SPECS
  3. vim openssh.spec
  4. # 307 行后添加
  5. install -m755 contrib/ssh-copy-id $RPM_BUILD_ROOT/usr/bin/ssh-copy-id
  6. # 390行后添加
  7. %attr(0755,root,root) %{_bindir}/ssh-copy-id
  1. # 修改版本openssl的版本 version.env
  2. OPENSSLSRC修改为openssl-1.1.1w.tar.gz

 编译打包

cd openssh-rpms && ./compile.sh el7

打包完成后二进制rpm包在目录openssh-rpms/el7/RPMS/x86_64下,源码包在openssh-rpms/el7/SRPMS/下,稍后我将放到我的资源中,若有需要的可自行下载。资源名称为:openssh9.6-centos7.3-x86-64.tgz,资源地址:https://download.csdn.net/download/qq_34777982/88668870

安装测试

  1. # 安装更新
  2. yum localinstall openssh-*.rpm
  3. # 授权
  4. chmod 600 /etc/ssh/ssh_host_*
  5. # 重启服务
  6. systemctl restart sshd && systemctl enable sshd --now
  7. # 检查服务状态
  8. systemctl status sshd

FAQ

1. 修改yum源

为什么要修改yum源,系统默认是最新的yum源,在安装依赖包的时候会升级版本和内核,而由于centos 7.3比较老,会出现诸多兼容性问题,因此我们需要将yum改为7.3的。

以下文件作为参考:

  1. cat /etc/yum.repos.d/CentOS-Vault.repo
  2. # CentOS Vault contains rpms from older releases in the CentOS-7
  3. # tree.
  4. #c7.3.1611
  5. [C7.3.1611-base]
  6. name=CentOS-7.3.1611 - Base
  7. baseurl=http://vault.centos.org/7.3.1611/os/$basearch/
  8. gpgcheck=1
  9. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  10. enabled=1
  11. [C7.3.1611-updates]
  12. name=CentOS-7.3.1611 - Updates
  13. baseurl=http://vault.centos.org/7.3.1611/updates/$basearch/
  14. gpgcheck=1
  15. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  16. enabled=1
  17. [C7.3.1611-extras]
  18. name=CentOS-7.3.1611 - Extras
  19. baseurl=http://vault.centos.org/7.3.1611/extras/$basearch/
  20. gpgcheck=1
  21. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  22. enabled=1
  23. [C7.3.1611-centosplus]
  24. name=CentOS-7.3.1611 - CentOSPlus
  25. baseurl=http://vault.centos.org/7.3.1611/centosplus/$basearch/
  26. gpgcheck=1
  27. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  28. enabled=1
  29. [C7.3.1611-fasttrack]
  30. name=CentOS-7.3.1611 - CentOSPlus
  31. baseurl=http://vault.centos.org/7.3.1611/fasttrack/$basearch/
  32. gpgcheck=1
  33. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  34. enabled=1
  35. # C7.1.1503
  36. [C7.1.1503-base]
  37. name=CentOS-7.1.1503 - Base
  38. baseurl=http://vault.centos.org/7.1.1503/os/$basearch/
  39. gpgcheck=1
  40. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  41. enabled=1
  42. [C7.1.1503-updates]
  43. name=CentOS-7.1.1503 - Updates
  44. baseurl=http://vault.centos.org/7.1.1503/updates/$basearch/
  45. gpgcheck=1
  46. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  47. enabled=1
  48. [C7.1.1503-extras]
  49. name=CentOS-7.1.1503 - Extras
  50. baseurl=http://vault.centos.org/7.1.1503/extras/$basearch/
  51. gpgcheck=1
  52. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  53. enabled=0
  54. [C7.1.1503-centosplus]
  55. name=CentOS-7.1.1503 - CentOSPlus
  56. baseurl=http://vault.centos.org/7.1.1503/centosplus/$basearch/
  57. gpgcheck=1
  58. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  59. enabled=0
  60. [C7.1.1503-fasttrack]
  61. name=CentOS-7.1.1503 - CentOSPlus
  62. baseurl=http://vault.centos.org/7.1.1503/fasttrack/$basearch/
  63. gpgcheck=1
  64. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  65. enabled=0
  66. # C7.2.1511
  67. [C7.2.1511-base]
  68. name=CentOS-7.2.1511 - Base
  69. baseurl=http://vault.centos.org/7.2.1511/os/$basearch/
  70. gpgcheck=1
  71. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  72. enabled=0
  73. [C7.2.1511-updates]
  74. name=CentOS-7.2.1511 - Updates
  75. baseurl=http://vault.centos.org/7.2.1511/updates/$basearch/
  76. gpgcheck=1
  77. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  78. enabled=0
  79. [C7.2.1511-extras]
  80. name=CentOS-7.2.1511 - Extras
  81. baseurl=http://vault.centos.org/7.2.1511/extras/$basearch/
  82. gpgcheck=1
  83. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  84. enabled=0
  85. [C7.2.1511-centosplus]
  86. name=CentOS-7.2.1511 - CentOSPlus
  87. baseurl=http://vault.centos.org/7.2.1511/centosplus/$basearch/
  88. gpgcheck=1
  89. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  90. enabled=0
  91. [C7.2.1511-fasttrack]
  92. name=CentOS-7.2.1511 - CentOSPlus
  93. baseurl=http://vault.centos.org/7.2.1511/fasttrack/$basearch/
  94. gpgcheck=1
  95. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  96. enabled=0

2. 查看防火墙状态

在未关闭selinux、firewalld防火墙的情况下仍然可以正常连接。 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/285813
推荐阅读
相关标签
  

闽ICP备14008679号