首页 > 工具脚本 > Centos7 升级SSH 到7.9p1的脚本【附安装包、sh】
2019
05-23

Centos7 升级SSH 到7.9p1的脚本【附安装包、sh】

脚本内容如下,文末附安装包和sh文件:

ps:请将文末压缩包里面的文件解压后传到服务器,并放在一个目录下,然后运行sh脚本即可。

#!/bin/bash

clear
echo ------------------------------------------
echo        CentOS7 openssh升级到7.9p1
echo               By feichai
echo         生产环境使用前请做好测试
echo ------------------------------------------
sleep 5s
clear
echo 安装进程开始
sleep 1s
clear
echo 安装进程开始  3
sleep 1s
clear
echo 安装进程开始  3  2
sleep 1s
clear
echo 安装进程开始  3  2  1
sleep 1s
clear
echo 安装并启动telnet服务端
sleep 2s
yum -y install xinetd telnet-server
cp /etc/securetty /etc/securetty.bak
echo "pts/0" >> /etc/securetty
echo "pts/1" >> /etc/securetty
systemctl restart telnet.socket &&  systemctl restart xinetd
sleep 1s
clear
echo 关闭SElinux并禁用……
sleep 2s
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
cat /etc/selinux/config
sleep 2s
clear
echo 安装程序依赖包……
sleep 2s
yum -y install gcc make perl zlib zlib-devel pam pam-devel
sleep 1s
clear
echo 停止并卸载原有ssh
sleep 2s
systemctl stop sshd
cp -r /etc/ssh /etc/ssh.old
rpm -qa | grep openssh
sleep 1s
rpm -e `rpm -qa | grep openssh` --nodeps
rpm -qa | grep openssh
sleep 1s
clear
echo 安装zlib
sleep 2s
tar -zxvf zlib-1.2.11.tar.gz 
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib && make && make install
ls -l /usr/local/zlib
sleep 1s
clear
echo 配置zlib
echo "/usr/local/zlib/lib" >> /etc/ld.so.conf.d/zlib.conf
ldconfig -v
cd ..
sleep 1s
clear
echo 安装openssl
sleep 2s
tar -zxvf openssl-1.0.2o.tar.gz
cd openssl-1.0.2o
./config shared zlib && make && make install
sleep 1s
clear
echo 配置openssl
sleep 2s
mv /usr/bin/openssl /usr/bin/openssl.bak
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf.d/ssl.conf
ldconfig -v
openssl version -a
cd ..
sleep 1s
clear
echo 安装openssh
sleep 2s
tar -zxvf openssh-7.9p1.tar.gz
cd openssh-7.9p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-privsep-path=/var/lib/sshd
make
sleep 1s
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
make install
sleep 1s
clear
echo 配置openssh
sleep 2s
echo "PasswordAuthentication yes"   >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
cp -p contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
chkconfig --add sshd
chkconfig sshd on
systemctl restart sshd
systemctl status sshd
sleep 1s
clear
echo 关闭并禁用telnet
sleep 1s
systemctl stop telnet.socket &&  systemctl stop xinetd
systemctl disable telnet.socket &&  systemctl disable xinetd
clear
echo 安装进程结束
sleep 3s
ssh -V


安装包、sh文件下载:本地下载



本文》有 0 条评论

留下一个回复