rpm包制作之openssh8.7升级

一、RPM包制作

以openssh为例,将源码包转换为二进制包,从openssh6.4升级至8.7。

源码下载地址:
https://www.linuxfromscratch.org/blfs/view/svn/postlfs/openssh.html
https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.7p1.tar.gz

据说目前升级openssh8.8不稳定,本次以8.7为测试

1)查看操作系统

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
[root@localhost ~]# ssh -V
OpenSSH_6.4p1, OpenSSL 1.0.1e-fips 11 Feb 2013

2)查看当前ssh包

[root@localhost ~]# rpm -qa | grep ssh
openssh-clients-6.4p1-8.el7.x86_64
openssh-server-6.4p1-8.el7.x86_64
libssh2-1.4.3-8.el7.x86_64
openssh-6.4p1-8.el7.x86_64
[root@localhost ~]# rpm -qf /usr/bin/ssh
openssh-clients-6.4p1-8.el7.x86_64
[root@localhost ~]# ps -ef | grep ssh
root       1107      1  0 04:03 ?        00:00:00 /usr/sbin/sshd -D
root       2120   1107  0 04:07 ?        00:00:00 sshd: root@pts/0
root       2129   1107  0 04:07 ?        00:00:00 sshd: root@notty
root       2146   2129  0 04:07 ?        00:00:00 /usr/libexec/openssh/sftp-server
root       2158   2124  0 04:11 pts/0    00:00:00 grep --color=auto ssh
[root@localhost ~]#

/usr/bin目录是二进制执行文件目录,主要用于具体应用
/usr/sbin目录是系统管理员专用的二进制代码存放目录,主要用于系统管理

3)rpmbuild 软件安装
rpmbuild 用于创建软件的二进制包和源代码包。

[root@localhost ~]# yum -y install rpm-build
[root@localhost ~]# rpmbuild
[root@localhost ~]# rpmbuild -h
用法: rpmbuild [选项...]
适用于 [ <specfile> | <tarball> | <source package> ] 的构建选项:-bp                           依据 <specfile> 从 %prep (解压缩源代码并应用补丁) 开始构建-bc                           依据 <specfile> 从 %build (%prep 之后编译) 开始构建-bi                           依据 <specfile> 从 %install (%prep、%build 后安装) 开始构建-bl                           依据 <specfile> 检验 %files 区域-ba                           依据 <specfile> 构建源代码和二进制软件包-bb                           依据 <specfile> 构建二进制软件包-bs                           依据 <specfile> 构建源代码软件包-tp                           依据 <tarball> 从 %prep (解压源代码并应用补丁)开始构建-tc                           依据 <tarball> 从 %build (%prep,之后编译)开始构建-ti                           依据 <tarball> 从 %install (%prep、%build 然后安装)开始构建-ta                           依据 <tarball> 构建源代码和二进制软件包-tb                           依据 <tarball> 构建二进制软件包-ts                           依据 <tarball> 构建源代码软件包--rebuild                     依据 <source package> 构建二进制软件包--recompile                   依据 <source package> 从 %install (%prep、%build 然后安装)开始构建--buildroot=DIRECTORY         重载构建根路径--clean                       完成后移除构建树--nobuild                     不执行任何构建步骤 --nodeps                      不检验构建依赖--nodirtokens                 生成和 rpm v3 包管理(旧版本)兼容的软件包头--noclean                     构建过程中不执行 %clean 步骤--nocheck                     构建过程中不执行 %check 步骤--rmsource                    完成时移除源代码--rmspec                      完成时移除 specfile--short-circuit               直接跳转到指定步骤 (仅限 c,i)--target=CPU-VENDOR-OS        重载目标平台所有 rpm 模式和可执行文件的通用选项:-D, --define=“MACRO EXPR”     定义值为 EXPR 的 MACRO--undefine=MACRO              undefine MACRO-E, --eval=“EXPR”             打印 EXPR 的宏展开--macros=<FILE:…>             从文件 <FILE:...> 读取宏,不使用默认文件--noplugins                   don't enable any plugins--nodigest                    不校验软件包的摘要--nosignature                 不验证软件包签名--rcfile=<FILE:…>             从文件 <FILE:...> 读取宏,不使用默认文件-r, --root=ROOT               使用 ROOT 作为顶级目录 (default: "/")--dbpath=DIRECTORY            使用 DIRECTORY 目录中的数据库--querytags                   显示已知的查询标签--showrc                      显示最终的 rpmrc 和宏配置--quiet                       提供更少的详细信息输出-v, --verbose                 提供更多的详细信息输出--version                     打印使用的 rpm 版本号Options implemented via popt alias/exec:--with=<option>               enable configure <option> for build--without=<option>            disable configure <option> for build--buildpolicy=<policy>        set buildroot <policy> (e.g. compress man pages)--sign                        generate GPG signature (deprecated, use command rpmsign instead)Help options:-?, --help                    Show this help message--usage                       Display brief usage message
[root@localhost ~]#

4)rpm包制作及依赖解决

[root@localhost ~]# rpmbuild -ba  openssh-8.7p1.tar.gz
错误:文件 /root/openssh-8.7p1.tar.gz 不像是 spec 文件。[root@localhost ~]# find / -name rpmbuild
/root/rpmbuild
/usr/bin/rpmbuild
[root@localhost ~]# cd /root/rpmbuild
[root@localhost rpmbuild]# ls
BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS
BUILD                编译rpm包的临时目录
BUILDROOT           编译后生成的软件临时安装目录
RPMS                最终生成的可安装rpm包的所在目录
SOURCES             所有源代码和补丁文件的存放目录
SPECS               存放SPEC文件的目录,制作rpm的文件
SRPMS               软件最终的rpm源码格式存放路径
创建对应存放目录
[root@localhost rpmbuild]# mkdir -p /root/rpmbuild/{SOURCES,SPECS}拷贝源码包到存放路径下
[root@localhost rpmbuild]# cp /root/openssh-8.7p1.tar.gz ./SOURCES/拷贝初始化的spec文件到rpmbuild中进行构建
[root@localhost ~]# tar -zxvf openssh-8.7p1.tar.gz -C /test
[root@localhost ~]# cp /test/openssh-8.7p1/contrib/redhat/openssh.spec /root/rpmbuild/SPECS/
[root@localhost ~]# cd  /root/rpmbuild/SPECS/
[root@localhost SPECS]# vi openssh.spec
[root@localhost SPECS]# ls
openssh.spec

解决打包出现的依赖报错

[root@localhost SPECS]# rpmbuild -ba openssh.spec
'''忽略'''
错误:构建依赖失败:openssl-devel >= 1.0.1 被 openssh-8.7p1-1.el7.x86_64 需要openssl-devel < 1.1 被 openssh-8.7p1-1.el7.x86_64 需要/usr/include/X11/Xlib.h 被 openssh-8.7p1-1.el7.x86_64 需要libXt-devel 被 openssh-8.7p1-1.el7.x86_64 需要imake 被 openssh-8.7p1-1.el7.x86_64 需要gtk2-devel 被 openssh-8.7p1-1.el7.x86_64 需要krb5-devel 被 openssh-8.7p1-1.el7.x86_64 需要[root@localhost SPECS]# vi openssh.spec
//在文件中注释或停用以上内容选项,将原先openssh.spec中的选项修改以下配置
%global no_x11_askpass 1
%global no_gnome_askpass 1
#BuildRequires: openssl-devel >= 1.0.1
#BuildRequires: openssl-devel < 1.1[root@localhost SPECS]# rpmbuild -ba openssh.spec
...忽略...
checking if openpty correctly handles controlling tty... yes
checking whether AI_NUMERICSERV is declared... yes
checking if SA_RESTARTed signals interrupt select()... yes
checking for getpgrp... yes
checking if getpgrp accepts zero args... yes
configure: error: *** working libcrypto not found, check config.log
错误:/var/tmp/rpm-tmp.QsWyiV (%build) 退出状态不好
RPM 构建错误:/var/tmp/rpm-tmp.QsWyiV (%build) 退出状态不好缺乏依赖安装依赖包,在此基本安装所缺依赖 (配置网络yum源)
[root@localhost SPECS]# yum -y install gcc zlib-devel openssl-devel perl-devel pam-devel x11-ssh
[root@localhost SPECS]# rpmbuild -ba openssh.spec
...忽略...
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
错误:坏文件:/root/rpmbuild/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz: 没有那个文件或目录
RPM 构建错误:坏文件:/root/rpmbuild/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz: 没有那个文件或目录[root@localhost SPECS]# wget https://src.fedoraproject.org/repo/pkgs/openssh/x11-ssh-askpass-1.2.4.1.tar.gz
[root@localhost SPECS]# mv x11-ssh-askpass-1.2.4.1.tar.gz  /root/rpmbuild/SOURCES/
[root@localhost SPECS]# rpmbuild -ba openssh.spec
...忽略...
写道:/root/rpmbuild/RPMS/x86_64/openssh-debuginfo-8.7p1-1.el7.x86_64.rpm
执行(%clean): /bin/sh -e /var/tmp/rpm-tmp.jQWbpI
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd openssh-8.7p1
+ rm -rf /root/rpmbuild/BUILDROOT/openssh-8.7p1-1.el7.x86_64
+ exit 0[root@localhost SPECS]# cd /root/rpmbuild/RPMS/x86_64   最终生成的可安装rpm包的所在目录
[root@localhost x86_64]# ls
openssh-8.7p1-1.el7.x86_64.rpm          openssh-debuginfo-8.7p1-1.el7.x86_64.rpm
openssh-clients-8.7p1-1.el7.x86_64.rpm  openssh-server-8.7p1-1.el7.x86_64.rpm

生产环境下开启telnet服务,避免ssh升级出现失败断开连接的问题

[root@localhost x86_64]#  tar zcvf openssh-8.7p1.tar.gz *.rpm
openssh-8.7p1-1.el7.x86_64.rpm
openssh-clients-8.7p1-1.el7.x86_64.rpm
openssh-debuginfo-8.7p1-1.el7.x86_64.rpm
openssh-server-8.7p1-1.el7.x86_64.rpm
[root@localhost x86_64]# sz openssh-8.7p1.tar.gz
[root@localhost x86_64]#

二、OpenSSH升级-RPM

备份原有配置文件
[root@localhost ~]# cp -r /etc/ssh/ /etc/ssh.bak/
[root@localhost ~]# cp -r /etc/pam.d/ /etc/pam.d.bak/升级安装
[root@localhost ~]# tar zxf openssh-8.7p1.tar.gz
[root@localhost ~]# rpm -Uvh openssh-*.rpm恢复原有的配置文件
[root@localhost ~]# cp -r -a /etc/ssh.bak /etc/ssh
[root@localhost ~]# cp -r -a /etc/pam.d.bak /etc/pam.d开启root远程访问
[root@localhost ~]# echo "PermitRootLogin yes" >> /etc/ssh/sshd_config重启服务
[root@localhost ~]# service sshd restart 或 systemctl restart sshd.service
[root@localhost ~]# ssh -V
OpenSSH_8.7p1, OpenSSL 1.0.2k-fips  26 Jan 2017
[root@localhost ~]#  rpm -qa | grep ssh
openssh-8.7p1-1.el7.x86_64
libssh2-1.8.0-4.el7.x86_64
openssh-debuginfo-8.7p1-1.el7.x86_64
openssh-server-8.7p1-1.el7.x86_64
openssh-clients-8.7p1-1.el7.x86_64
[root@localhost ~]# rpm -qf /usr/bin/ssh
openssh-clients-8.7p1-1.el7.x86_64------------其他参考(连接问题等补充)-----------
rm -rf /etc/ssh/ssh_host_*   删除原有密钥
vi /etc/ssh/sshd_config      修改配置文件参数PermitRootLogin yes、PubkeyAuthentication yes、PasswordAuthentication yes
cat /var/log/messages | grep network     日志排查网卡断开问题
systemctl stop NetworkManager       关闭网络守护进程
systemctl disable NetworkManager    永久关闭网络守护进程
service network restart             重启网卡

rpm包制作之openssh8.7升级相关推荐

  1. OpenSSH升级8.5版本rpm包制作过程及安装。OpenSSH 命令注入漏洞

    OpenSSH升级8.5版本 3月3日OpenSSH官方发布最新版OpenSSH8.5,此次更新修复了之前版本存在的注入漏洞.用源码编译的方式比较慢 而且需要相关的依赖特别的多,而且公司一般都是内网环 ...

  2. linux rpm 包制作详解

    一.RPM介绍 RPM 前是Red Hat Package Manager 的缩写,本意是Red Hat 软件包管理,顾名思义是Red Hat 贡献出来的软件包管理:现在应为RPM Package M ...

  3. linux怎么制作运行包,简单 RPM 包制作

    今天为了测试搭建自己的yum仓库并安装升级软件包,因此需要一个rpm包来做测试,所以就想到了自己来做一个最简单rpm,因为仅仅就是做一个测试所以没有添加需要编译的文件,而是只使用了一个shell文件来 ...

  4. linux yum仓库制作,yum仓库搭建之RPM包制作

    常见的软件安装方式有以下几种 1.yum安装,可自动解决依赖,但不能自定义软件安装位置 2.编译安装,可指定安装路径,指定装模块,但编译参数冗长,且耗时较长,不能解决依赖问题. 3.rpm安装,安装速 ...

  5. Openssh rpm 包制作

    0X01 下载openssh 源文件 rpm包制作的前期各种文件略过,我选择在http://mirror.aarnet.edu.au/pub/OpenBSD/OpenSSH/portable/ 下载合 ...

  6. rpm包制作介绍及实战操作讲解01(学生分享)

    说明:本文来自老男孩linux运维实战培训-高级架构师班学生分享内容,本文分为两部分,此为第一部分. 第一次观看本视频前,建议博友先观看:人人都是讲师的教学培训体系介绍 http://oldboy.b ...

  7. RPM包制作及yum仓库搭建

    RPM包制作 rpm包的制作是通过fpm软件来生成的,所以首先要安装fpm软件.又因为fpm的软件是ruby开发的,所以安装fpm的话首先要安装ruby等包 FPM功能简单说就是将一种类型的包转换成另 ...

  8. 内网环境下使用rpm包制作yum数据源及使用

    内网环境下使用rpm包制作yum数据源及使用 在实际生产环境中,绝大多数服务器处于内网环境.基于最小化安装.光盘镜像挂载不方便(缺少)等原因,无法使用yum服务,本实验基于生产环境中出现的上述现象进行 ...

  9. 使用rpm包制作本地镜像仓库和使用httpd发布镜像服务实现内网使用yum命令

    记录:313 场景:在CentOS 7.9操作系统,使用reposync命令下载rpm包:使用createrepo把rpm包制作成本地镜像仓库:使用httpd发布本地镜像服务:实现内网环境使用yum命 ...

最新文章

  1. 关于一道简单的Java 基础面试题的剖析: short s1=1;s1 = s1 +1会报错吗?
  2. ftp 工具_ftp工具,ftp工具如何下载使用?Linux如何配置ftp服务器?
  3. java 编辑我的世界_Editing Java版1.13 (section)
  4. spring mvc+spring + hibernate 整合(二)
  5. Jpa规范原始编程步骤
  6. 大端机,小端机;截断与提升
  7. 【Flink】flink keyby 在 subtask 中分配不均的研究
  8. 服务器登陆地址怎么修改,服务器登陆地址怎么修改
  9. MySQL命令行导入导出sql文件
  10. pagehelper中找不到pageinterceptor这个类_PageHelper分页插件
  11. 数据结构视频教程 -《[北风网]C#版数据结构与算法高级教程》
  12. 《自己动手写操作系统》之 10分钟完成最小的操作系统
  13. 高数_第6章无穷级数_函数的幂级数展开式_马克劳林级数
  14. 【Python】PDF转图片
  15. H3C防火墙-安全域
  16. 【PPT】跨境电商的N个知识点普及
  17. 6.STC15W408AS单片机外部中断
  18. C++ 学习笔记(19)new/delete表达式、定位new、typeid、dynamic_cast、type_info、枚举类型、成员函数指针、union、位域、volatile限定符、链接指示
  19. Linux ssh免密登录
  20. Java基础部分 阶段一(语法基础)1、开发环境搭建(计算机编程及开发语言)

热门文章

  1. Arduino开发教程汇总
  2. spring boot 和cloud 版本升级
  3. 视频监控存储空间大小与传输带宽计算方法
  4. vue3 el-table结合seamless-scroll实现表格数据滚动
  5. 指向性麦克风--心形麦克风设计(五)
  6. html中onload的使用
  7. 第二阶段--团队冲刺--第三天
  8. 商品规格属性(SKU)组合算法
  9. ASP.NET集成PayPal(使用IPN)
  10. 查找替换之 换行符替换