linux ssh rpm包,Linux openssh rpm包制作

https://www.cnblogs.com/liweiming/p/11571841.html

https://blog.51cto.com/13654115/2452631?source=dra

制作6系统使用的包,在六系统上制作,制作7系统使用的包。在7系统上面制作,下载相关依赖包

yum install rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel unzip -y

yum install libXt* -y

yum install imake* -y

yum install gtk2* -y

mkdir -p /root/rpmbuild/{SOURCES,SPECS}

cd /root/rpmbuild/SOURCES

wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz

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

tar zxvf openssh-8.4p1.tar.gz  openssh-8.4p1/contrib/redhat/openssh.spec

mv openssh-8.4p1/contrib/redhat/openssh.spec ../SPECS/

chown sshd:sshd /root/rpmbuild/SPECS/openssh.spec

cp /root/rpmbuild/SPECS/openssh.spec /root/rpmbuild/SPECS/openssh.spec_def

sed -i -e "s/%define no_gnome_askpass 0/%define no_gnome_askpass 1/g" /root/rpmbuild/SPECS/openssh.spec

sed -i -e "s/%define no_x11_askpass 0/%define no_x11_askpass 1/g" /root/rpmbuild/SPECS/openssh.spec

cd /root/rpmbuild/SPECS/

vi openssh.spec

注释掉 BuildRequires: openssl-devel < 1.1 因为目前安装的版本都低于1.1

cd /root/rpmbuild/SPECS/

rpmbuild -ba openssh.spec

---需要修改ssh_config内容

cp /etc/init.d/sshd /root/

cp /etc/pam.d/sshd /etc/pam.d/sshd.old

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.old

cat /etc/pam.d/sshd.old > /etc/pam.d/sshd

cat /etc/ssh/sshd_config.old > /etc/ssh/sshd_config

ln -s /usr/lib64/libcrypto.so.1.0.1e  /usr/lib64/libcrypto.so.10

ln -s /usr/lib64/libcrypto.so.1.0.1e  /usr/lib64/libcrypto.so

ln -s /usr/lib64/libssl.so.1.0.1e /usr/lib64/libssl.so

ln -s /usr/lib64/libssl.so.1.0.1e /usr/lib64/libssl.so.10

ln -s libcrypto.so.1.0.1e  libcrypto.so

ln -s libssl.so.1.0.1e  libssl.so

rpm -Uvh *.rpm

rm -rf /etc/ssh/ssh_host_*key

/etc/init.d/sshd restart >/dev/null 2>&1

安装注意:

########################################

Vi修改/etc/ssh/sshd_config文件,修改如下内容:

#PermitRootLogin prohibit-password  修改为PermitRootLogin yes

#UsePAM no 修改为  UsePAM yes

/etc/pam.d/sshd  要覆盖原来的文件  不然密码验证不通过

cp /etc/pam.d/sshd /etc/pam.d/sshdbak

https://www.openssl.org/source/

#!/bin/bash

##########################################################

##                                                      ##

## Script Name:install-openssh for Redhat-CenOS-6.0~7.6 ##

## By:Eren 2019-08-29                                  ##

##                                                      ##

##########################################################

###

echo ---- config file copy ......Please Wait ----

cp /etc/pam.d/sshd /tmp/

cp /etc/ssh/sshd_config /tmp/

if [ $? == 1 ]

then

echo "cp failed "

exit 0

fi

###

echo ---- install-openssh ......Please Wait ----

###

os=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'`

if [ $os == 6 ];then

rpm -Uvh *el6*.rpm

else

rpm -Uvh  *el7*.rpm

fi

echo ---- install-openssh installation is Complete ----

###

cat /tmp/sshd >  /etc/pam.d/sshd

cat /tmp/sshd_config > /etc/ssh/sshd_config

###

#sed -i '/#UsePAM no/a\UsePAM yes' /etc/ssh/sshd_config

###

rm -rf /etc/ssh/ssh_host_*key

/etc/init.d/sshd restart >/dev/null 2>&1

###

ssh -V

1 开始telnet

前期准备,开启telnet端口

mv /etc/securetty /etc/securetty.bak

vi /etc/xinetd.d/telnet

# disable  = yes

service xinetd restart

chkconfig --add sshd

chkconfig sshd on

chkconfig --list sshd

一、Failed to start SYSV: OpenSSH server daemon.

chmod 600 /etc/ssh/ssh_host_rsa_key

chmod 600 /etc/ssh/ssh_host_ecdsa_key

chmod 600 ssh_host_ed25519_key

二、经过排查发现是ssh rpm 升级后会修改/etc/pam.d/sshd 文件,需要备份此文件,升级完还原此文件。还原后的文件内容为:

https://blog.csdn.net/weixin_37565541/article/details/93488866

#%PAM-1.0

auth      required    pam_sepermit.so

auth      include      password-auth

account    required    pam_nologin.so

account    include      password-auth

password  include      password-auth

# pam_selinux.so close should be the first session rule

session    required    pam_selinux.so close

session    required    pam_loginuid.so

# pam_selinux.so open should only be followed by sessions to be executed in the user context

session    required    pam_selinux.so open env_params

session    optional    pam_keyinit.so force revoke

session    include      password-auth

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值