麒麟V10 openssh9.6p1 rpm包制作

1、下载源码包

https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.6p1.tar.gz

 

 

2、解压,并从中得到openssh.spec

路径  .\openssh-9.6p1\contrib\redhat\openssh.spec

 

3、如果要添加ssh-copy-id命令

添加如下命令

 

#280行新增

install -m755 contrib/ssh-copy-id $RPM_BUILD_ROOT/usr/bin/ssh-copy-id 

#386行新增

%attr(0755,root,root) %{_bindir}/ssh-copy-id

 

 4、搭建编译环境

dnf -y install rpm-build gcc gcc-c++ glibc glibc-devel   pcre pcre-devel zlib zlib-devel perl perl-devel make imake wget xmkmf   initscripts  krb5-devel pam-devel krb5-devel libX11-devel libXt-devel gtk2-devel 

 

5、开始编译

rpmbuild -ba /root/rpmbuild/SPECS/openssh.spec   

 

6、安装脚本(ssh9.6_install.sh)如下

#!/bin/bash
#
#########################################################
# Function :openssh-9.6p1 update                        #
# Platform :ky10                                   #
# Version  :2.0                                         #
# Date     :2024-03-05                                  #
#########################################################
clear
export LANG="en_US.UTF-8"

# 1、备份文件
echo -e "\e[34m 1、备份文件 \e[0m"
\cp /etc/pam.d/sshd /etc/pam.d/sshd_bak
\cp /etc/ssh/sshd_config /etc/ssh/sshd_config_bak

# 2、安装
echo -e "\e[34m 2、安装 \e[0m"
rpm -Uvh ./openssh-*.rpm --nodeps
\cp /etc/pam.d/sshd /etc/pam.d/sshd_bak.new

# 3、恢复
echo -e "\e[34m 3、恢复 \e[0m"
\cp /etc/ssh/sshd_config.rpmnew /etc/ssh/sshd_config
\cp /etc/pam.d/sshd_bak /etc/pam.d/sshd

chmod +755 /etc/ssh/sshd_config
chmod +755 /etc/pam.d/sshd

# 4、修改
echo -e "\e[34m 4、修改 \e[0m"
echo "PermitRootLogin yes                          #允许root帐号远程登录"  >> /etc/ssh/sshd_config
echo "PasswordAuthentication yes         #开启密码认证方式"  >> /etc/ssh/sshd_config
echo "UsePAM yes                          #开启UsePAM登录"  >> /etc/ssh/sshd_config

# 5、重启服务
echo -e "\e[34m 5、重启服务 \e[0m"
systemctl daemon-reload
systemctl restart sshd

# 6、检查版本
echo -e "\e[34m 6、检查版本 \e[0m"
rpm -qa | grep openssh
openssl version
ssh -V

# 测试远程连接
echo -e "\e[34m 7、测试远程连接 \e[0m"
echo "请测试远程连接"

 

posted on 2024-03-05 17:25  -0.5拍  阅读(444)  评论(0编辑  收藏  举报