openssh 编译安装 封装rpm

发布时间 2023-08-22 16:26:25作者: 秉烛夜游~游山玩水
tar -zxf openssl-1.1.0k. tar.gz
yum -y install wget pam*
yum install -y perl  rpm-build gcc gcc-c+i glibc glibc-devel openss1-devel openssl prce pcre-devel zlib zlib-devel

cd /root/openssh/openssl-1.1.1v
./config --prefix=/openssh9.4p1 --openssldir=/openssh9.4p1/openssl  zlib-dynamic shared
make depend
make
make test
make install
echo '/openssh9.4p1/lib' >>/etc/ld.so.conf
ldconfig

tar -zxf openssh-8.3p1.tar.gz
cd openssh-8.3p1
vi version.sh

yum -y install pam-devel
cd /root/openssh/openssh-9.3p1
./configure --prefix=/openssh9.4p1 --with-ssl-dir=/openssh9.4p1   --with-selinux 
make
make install
echo 'export PATH=/openssh9.4p1/bin:/openssh9.4p1/sbin:$PATH' >/etc/profile.d/ssh.sh
source /etc/profile.d/ssh.sh

cp -a /etc/sysconfig/sshd /openssh9.4p1/etc/sshd #
cp /etc/init.d/sshd /etc/init.d/sshd.old

PasswordAuthentication yes
PermitRootLogin yes

fpm -s dir -t rpm -n openssh -v 9.4p1-ssl1.1.1v --description "Install standalone 'openssh' to path [/openssh 9.4]"   \ 

  

[root@adminsvr1 openssh9.4]# cat 1.ssh_install_rpm9.4p1.sh 
#!/bin/bash
#Athor: zhanghe
#Create time: Wed 09 Mar 2023 18:12:34 CST
#filename:ssh_install_rpm.sh
#Script description:
#usage:
sed -i '/openssh9.4p1/d' /etc/rc.d/rc.local
sed -i '/openssh9.4p1/d' /etc/ld.so.conf
sed -i '/openssh9.4p1/d' /etc/profile
cat /etc/selinux/config | grep SELINUX=enforcing > /dev/null 2>&1
if [ $? -eq 0 ];then
  sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  setenforce 0
fi
systemctl stop sshd
sleep 2
sed -i '$a/openssh9.4p1/lib' /etc/ld.so.conf
ldconfig
echo 'export PATH=/openssh9.4p1/bin:/openssh9.4p1/sbin:$PATH' > /etc/profile.d/openssh9.4p1.sh

source /etc/profile.d/openssh9.4p1.sh

sleep 1

cat > /usr/lib/systemd/system/sshd.service <<EOFL
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.service
Wants=sshd-keygen.service

[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/sshd
ExecStart=/openssh9.4p1/sbin/sshd -D \$OPTIONS
ExecReload=/bin/kill -HUP \$MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

EOFL

systemctl daemon-reload

systemctl restart sshd
systemctl enable sshd > /dev/null 2>&1
ssh -V
echo "执行:source /etc/profile"
[root@adminsvr1 openssh9.4]#

  

[root@adminsvr1 openssh9.4]# cat 1.ssh_remove_rpm9.4p1.sh 
#!/bin/bash
#Athor: zhanghe
#Create time: Wed 09 Mar 2023 18:12:34 CST
#filename:ssh_reomve_rpm.sh
#Script description:
#usage:
sed -i '/openssh9.4p1/d' /etc/rc.d/rc.local
sed -i '/openssh9.4p1/d' /etc/ld.so.conf
sed -i '/openssh9.4p1/d' /etc/profile
rm -vrf /openssh9.4p1/
rm -vf /etc/profile.d/openssh9.4p1.sh
cat /etc/selinux/config | grep SELINUX=enforcing > /dev/null 2>&1
if [ $? -eq 0 ];then
  sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  setenforce 0
fi
systemctl stop sshd
sleep 2
ldconfig
source /etc/profile

cat > /usr/lib/systemd/system/sshd.service <<EOFL
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.service
Wants=sshd-keygen.service

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -D \$OPTIONS
ExecReload=/bin/kill -HUP \$MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

EOFL

systemctl daemon-reload

systemctl restart sshd
systemctl enable sshd > /dev/null 2>&1
ssh -V
echo "执行:source /etc/profile"
[root@adminsvr1 openssh9.4]#