Linux openssh8.0p1升级步骤(shell版本)
运维自动化时代,手动升级太徒劳了,为了提高效率及准确率,自动化安装是必备的。
下面是通过shell写的脚本。也可以将其应用到ansible上.
准备好安装文件:
openssh-8.0p1.tar.gz
openssl-1.1.0k.tar.gz
zlib-1.2.11.tar.gz
openssl-fips-2.0.16.tar.gz
perl-5.10.0.tar.gz(redhat5以下需要,由于编辑openssl,perl版本最底为5.10.0)
脚本内容如下:
#!/bin/bash
#
#setup && update openssh8.0p1 #Action state
mstate(){
if [ $? -eq 0 ];then
echo "--------------------------By installing--------------------------"
else
echo "--------------------------Installation failed--------------------"
exit 1
fi
} MDIR=`pwd` #zlib1.2.11
mzlib(){
if [ -d /usr/local/zlib-1.2.11 ];then
echo "------------------------zlib-1.2.11 installation complete------------"
else
echo "-----------------------Start setup zlib------------------------------"
cd $MDIR
tar -xzvf zlib-1.2.11.tar.gz >> /dev/null
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib-1.2.11 && make && make install
mstate
fi
} #openssl-fips
mopenssl_fips(){
if [ -d /usr/local/ssl/fips-2.0 ];then
echo "-------------openssl-fips-2.0 installation complete-----------------"
else
cd $MDIR
tar -xzvf openssl-fips-2.0.16.tar.gz >> /dev/null
cd openssl-fips-2.0.16
./config && make && make install
mstate
fi
} mperl(){
if [ -d /usr/local/perl-5.10.0 ];then
echo "-------------perl-5.10.0 installation complete----------------------"
else
cd $MDIR
tar -xzvf perl-5.10.0.tar.gz >> /dev/null
cd perl-5.10.0
./configure.gnu -des -Dprefix=/usr/local/perl-5.10.0 && make && make install
mstate
export PATH=/usr/local/perl-5.10.0/bin:$PATH
fi
}
#openssl-1.1.0k
mopenssl(){
if [ -d /usr/local/openssl-1.1.0k ];then
echo "---------------openssl-1.1.0k installation complete----------------"
else
echo "-------------------Start setup openssl-----------------------------"
cd $MDIR
tar -xzvf openssl-1.1.0k.tar.gz >> /dev/null
cd openssl-1.1.0k
./config --prefix=/usr/local/openssl-1.1.0k --with-fipslibdir=/usr/local/ssl/fips-2.0/lib/ && make && make install
mstate
grep /usr/local/openssl-1.1.0k/lib/ /etc/ld.so.conf
if [ $? -ne 0 ];then
echo "/usr/local/openssl-1.1.0k/lib/" >> /etc/ld.so.conf
fi
ldconfig
fi
} #openssh-8.0p1
mopenssh(){
if [ -d /usr/local/openssh-8.0p1 ];then
echo "---------------------openshh-8.0p1 installation complete----------"
else
echo "----------------------Start setup openssh-------------------------"
mopenssh_bak
cd $MDIR
tar -xzvf openssh-8.0p1.tar.gz >> /dev/null
cd openssh-8.0p1
./configure --prefix=/usr/local/openssh-8.0p1 --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl-1.1.0k --with-zlib=/usr/local/zlib-1.2.11 --with-md5-passwords && make && make install
mstate
fi
} #openssh bak
mopenssh_bak(){
echo "--------bak old openssh config files---------------------------------"
if [ -d /etc/ssh ];then
mv /etc/ssh /etc/ssh_`date +%Y%m%d`
echo "-----------------------/etc/ssh mv complete------------------------"
else
echo "---------------------/etc/ssh no exist-----------------------------"
fi
} #openssh config (redhat 5 6)
mopenssh_config(){
\cp -a $MDIR/openssh-8.0p1/contrib/redhat/sshd.init /etc/init.d/sshd
sed -i 's/SSHD=\/usr\/sbin\/sshd/SSHD=\/usr\/local\/openssh-8.0p1\/sbin\/sshd/g' /etc/init.d/sshd
sed -i 's/\/usr\/bin\/ssh-keygen -A/\/usr\/local\/openssh-8.0p1\/bin\/ssh-keygen -A/g' /etc/init.d/sshd
chkconfig --add sshd
chkconfig sshd on
} mopenssh_config7(){
\cp -a $MDIR/openssh-8.0p1/contrib/redhat/sshd.init /etc/init.d/sshd
sed -i 's/SSHD=\/usr\/sbin\/sshd/SSHD=\/usr\/local\/openssh-8.0p1\/sbin\/sshd/g' /etc/init.d/sshd
sed -i 's/\/usr\/bin\/ssh-keygen -A/\/usr\/local\/openssh-8.0p1\/bin\/ssh-keygen -A/g' /etc/init.d/sshd
if [ -f /usr/lib/systemd/system/ssh* ];then
mv -f /usr/lib/systemd/system/ssh* $MDIR
echo "-------------------move redhat7 systemctl sshd.service-----------"
else
echo "-------------------redhat7 systemctl sshd.service no file--------"
fi
chkconfig --add sshd
chkconfig sshd on
} #openssh path
mopenssh_path(){
grep "export PATH=/usr/local/openssh-8.0p1/bin:$PATH" /etc/profile
if [ $? -ne 0 ];then
echo "export PATH=/usr/local/openssh-8.0p1/bin:$PATH" >> /etc/profile
source /etc/profile
fi
} magain(){
read -p "Please try again(y/Y) :" mresult
if [ $mresult == 'y' ] || [ $mresult == 'Y' ];then
echo "***************************************************************"
else
echo "**********************Question*********************************"
exit 1
fi
} mrestart(){
echo "---------------------------sshd service restart--------------------"
service sshd restart } m5(){
echo "-------------------------------------------------------------------"
sleep 3
mzlib
echo "-------------------------------------------------------------------"
sleep 3
mopenssl_fips
echo "-------------------------------------------------------------------"
sleep 3
mperl
echo "-------------------------------------------------------------------"
sleep 3
mopenssl
echo "-------------------------------------------------------------------"
sleep 3
mopenssh
echo "-------------------------------------------------------------------"
sleep 3
mopenssh_config
echo "-------------------------------------------------------------------"
sleep 3
mopenssh_path
echo "-------------------------------------------------------------------"
} m6(){
echo "-------------------------------------------------------------------"
sleep 3
mzlib
echo "-------------------------------------------------------------------"
sleep 3
mopenssl_fips
echo "-------------------------------------------------------------------"
sleep 3
mopenssl
echo "-------------------------------------------------------------------"
sleep 3
mopenssh
echo "-------------------------------------------------------------------"
sleep 3
mopenssh_config
echo "-------------------------------------------------------------------"
sleep 3
mopenssh_path
echo "-------------------------------------------------------------------"
} m7(){
echo "-------------------------------------------------------------------"
sleep 3
mzlib
echo "-------------------------------------------------------------------"
sleep 3
mopenssl_fips
echo "-------------------------------------------------------------------"
sleep 3
mopenssl
echo "-------------------------------------------------------------------"
sleep 3
mopenssh
echo "-------------------------------------------------------------------"
sleep 3
mopenssh_config7
mopenssh_config
echo "-------------------------------------------------------------------"
sleep 3
mopenssh_path
echo "-------------------------------------------------------------------"
mrestart
}
#system_release
echo "-------------------------system release----------------------------"
cat /etc/redhat-release
echo "---------------------------select release--------------------------"
PS3="Please select a number(1,2,3,4) :"
select mrelease in redhat5 redhat6 redhat7 Quit
do
case $mrelease in
redhat5)
echo "Start $mrelease Setup openssh"
echo "---------------------you select redhat5----------------------"
magain
echo "--------------------------------------------------------------"
m5
echo "--------------------------------------------------------------"
;;
redhat6)
echo "Start $mrelease Setup openssh"
echo "---------------------you select redhat6-----------------------"
magain
echo "--------------------------------------------------------------"
m6
echo "--------------------------------------------------------------"
;;
redhat7)
echo "Start $mrelease Setup openssh"
echo "---------------------you select redhat7-----------------------"
magain
echo "--------------------------------------------------------------"
m7
echo "--------------------------------------------------------------"
;;
Quit)
echo "---------------------Goodble----------------------------------"
exit 0
;;
*)
echo "---------------------Sorry, No release------------------------"
;;
esac
done
Linux openssh8.0p1升级步骤(shell版本)的更多相关文章
- Linux openssh8.0p1升级步骤
前期准备开启本机telnet服务,以防openssh升级失败无法连接服务器.注:redhat 5 6 和 redhat7 开机启动配置相关文件不同,请注意 1.安装zlibtar -xzvf zlib ...
- Linux下python升级步骤
先安装openssl,openssl-devel yum install openssl yum install openssl-devel 1切换到指定的目录下: cd /usr/local 2下载 ...
- linux python2.x 升级python3.x
Linux下python升级步骤 Python2 ->Python3 多数情况下,系统自动的Python版本是2.x 或者yum直接安装的也是2.x 但是,现在多数情况下建议使用3.x 那么如 ...
- centos7 升级openssh到openssh-8.0p1版本
环境介绍 centos7.3和centos7.6升级完毕测试登录ssh以及重启后登录ssh均无问题. 前期请自行配置好yum源(如果不会请百度) 整个过程不需要卸载原先的openssl包和openss ...
- Linux系统下升级Python版本步骤(suse系统)
Linux系统下升级Python版本步骤(suse系统) http://blog.csdn.net/lifengling1234/article/details/53536493
- Linux下python版本的升级步骤
1.先下载,你要升级的python版本(我升级的是python3.3.0) 可使用系统自带下载工具wget下载: wget http://www.python.org/ftp/python/3.3.0 ...
- 在Linux运行期间升级Linux系统(Uboot+kernel+Rootfs)
版本:v1.2 Crifan Li 摘要 本文主要介绍了如何在嵌入式Linux系统运行的时候,进行升级整个Linux系统,包括uboot,kernel和rootfs.以及简介Linux中的已有的通 ...
- mongo - 升级步骤
升级步骤1. 关闭balancer登陆mongos,执行sh.stopBalancer(),或者 连接到mongos>use config>db.settings.update( { _i ...
- mysql在linux下的安装(5.7版本以后)
1.添加mysql组和mysql用户,用于设置mysql安装目录文件所有者和所属组. ①groupadd mysql ②useradd -r -g mysql mysql 2.将二进制文件解压到指定的 ...
随机推荐
- 深入理解php的输出缓冲区(output buffer)
这篇文章是翻译自Julien Pauli的博客文章PHP output buffer in deep,Julien是PHP源码的资深开发和维护人员.这篇文章从多个方面讲解了PHP中的输出缓冲区以及怎么 ...
- legend3---Windows 7/8/10 系统下Laravel框架的开发环境安装及部署详解(Vagrant + Homestead)
legend3---Windows 7/8/10 系统下Laravel框架的开发环境安装及部署详解(Vagrant + Homestead) 一.总结 一句话总结: 1.安装的话就是下载好git,va ...
- kafka-manager怎么查看topic里的数据量
https://jingyan.baidu.com/article/eb9f7b6d367679869364e8d4.html
- 惠普服务器DL360G6安装ESXi主机后遗忘密码用u盘重置密码
惠普服务器DL360G6安装ESXi主机后遗忘密码重置密码 先用rufus制作U盘启动盘,启动盘一定要用惠普专用hpe的esxi版本,否则安装会报错, 下载https://www.iplaysoft. ...
- post与get方法的区别
1. GET请求:请求的数据会附加在URL之后,以?分割URL和传输数据,多个参数用&连接.URL的编码格式采用的是ASCII编码,而不是unicode,即是说所有的非ASCII字符都要编码之 ...
- 配置Log4j(很详细)【转】
来自: http://www.blogjava.net/zJun/archive/2006/06/28/55511.html Log4J的配置文件(Configuration File)就是用来设置记 ...
- 阶段3 1.Mybatis_05.使用Mybatis完成CRUD_2 Mybatis的CRUD-保存操作
增加的方法 修改映射配置 id是方法名 按照原来jdbc的写法 values里面应该是一堆问号,现在这里不能再去写问号了因为要取值 从我们要执行的方法传的参数里面去取值 所以参数的类型我们必须要告诉这 ...
- spring(二) AOP注入
AOP概念 l AOP采取横向抽取机制,取代了传统纵向继承体系重复性代码 l 经典应用:事务管理.性能监视.安全检查.缓存 .日志等 l Spring AOP使用纯Java实现,不需要专门的编译 ...
- [ScreenOS] How to manually generate a new system self-signed certificate to replace the expired system self-signed certificate without resetting the firewall
SUMMARY: This article provides information on how to manually generate a new system self-signed cert ...
- SPA应用性能优化(懒加载)
前提: 如今开发方式都是采用前后台分离的方式,前台采用的方式则是单页面应用开发简称SPA,这种开发模式最大的一个特点就是将有所代码打包成了一个文件, 这会导致了一个问题就是如果这个应用过大,打出来的这 ...