变量说明

SSL_N=openssl-1.0.2p #ssl 版本
SSH_N=openssh-7.9p1 #ssh 版本
ZLIB_N=zlib-1.2.11 # zlib 版本

脚本分为两个,因为升级ssh ssh存在断开问题,需要临时启用telnet继续执行

yum配置采用了ftp yum源,具体配置见我的博客:

https://www.cnblogs.com/levi-w/p/9675157.html

执行步骤:

1 首先在服务器执行openssh-update.telnet.sh

2 telnet 登录服务器,执行openssh-update.sh

脚本详情:

1 openssh-update.telnet.sh

#!/bin/bash
#config yum
export SSL_N=openssl-1.0.2p
export SSH_N=openssh-7.9p1
export ZLIB_N=zlib-1.2.11

cp -r /etc/yum.repos.d /etc/yum.repos.d_bak
rm -rf /etc/yum.repos.d/*

echo "[CenterOS-source]
name=Linux "'$releasever'" - "'$basearch'" - Source
baseurl=ftp://10.1.1.1/pub/cos6
enabled=1
gpgcheck=0" > /etc/yum.repos.d/rhel-source.repo

yum makecache

yum -y install gcc* telnet* pam-devel openssl-devel

##config telnet#一定要测试!
yum -y install telnet*
# disable字段改为no
sed -i '12c disable = no' /etc/xinetd.d/telnet
service xinetd restart
mv /etc/securetty /etc/securetty.bak

read -p "test telnet[y/n]: " number
if [ $number != 'y' ]
then
echo "Error"
exit
fi
echo "please use telnet to countinue"

2 openssh-update.sh

#!/bin/bash
#config yum
export SSL_N=openssl-1.0.2p
export SSH_N=openssh-7.9p1
export ZLIB_N=zlib-1.2.11

##config zlib
cd /opt
tar zxvf /opt/$ZLIB_N.tar.gz

cd /opt/$ZLIB_N/
./configure --prefix=/usr/local/$ZLIB_N -share
cd /opt/$ZLIB_N/
make -j4
make -j4 test
read -p "test $ZLIB_N [y/n]: " number
if [ $number != 'y' ]
then
echo "Error"
exit
fi
make -j4 install

mv /usr/local/$ZLIB_N/lib/libz.a /usr/local/$ZLIB_N/lib/libz.a.bak`date +%y%m%d`
/bin/cp -r /opt/$ZLIB_N/libz.a /usr/local/$ZLIB_N/lib
chmod 644 /usr/local/$ZLIB_N/lib/libz.a
/bin/cp -r /opt/$ZLIB_N/ libz.so.1.2.11 /usr/local/$ZLIB_N/lib
chmod 755 /usr/local/$ZLIB_N/lib/libz.so.1.2.11
mv /usr/local/$ZLIB_N/share/man/man3/zlib.3 /usr/local/$ZLIB_N/share/man/man3/zlib.3.bak`date +%y%m%d`
/bin/cp -r /opt/$ZLIB_N/zlib.3 /usr/local/$ZLIB_N/share/man/man3
mv /usr/local/$ZLIB_N/lib/pkgconfig/zlib.pc /usr/local/$ZLIB_N/lib/pkgconfig/zlib.pc.bak`date +%y%m%d`
cp -r /opt/$ZLIB_N/zlib.pc /usr/local/$ZLIB_N/lib/pkgconfig
chmod 644 /usr/local/$ZLIB_N/lib/pkgconfig/zlib.pc
mv /usr/local/$ZLIB_N/include/zlib.h /usr/local/$ZLIB_N/include/zlib.h.bak`date +%y%m%d`
mv /usr/local/$ZLIB_N/include/zconf.h /usr/local/$ZLIB_N/include/zconf.h.bak`date +%y%m%d`
/bin/cp -r /opt/$ZLIB_N/zlib.h zconf.h /usr/local/$ZLIB_N/include
chmod 644 /usr/local/$ZLIB_N/include/zlib.h /usr/local/$ZLIB_N/include/zconf.h

echo "include ld.so.conf.d/*.conf
## add for update ssh
/usr/local/$ZLIB_N/lib
##add end">>/etc/ld.so.conf
ldconfig -v

ln -s /usr/local/$ZLIB_N /usr/local/zlib

##install openssl
cp -r /usr/lib64/openssl /usr/lib64/openssl_old
cp -r /usr/bin/openssl /usr/bin/openssl_old

cd /opt
tar zxvf /opt/$SSL_N.tar.gz
cd /opt/$SSL_N/
./config zlib-dynamic --prefix=/usr/local/$SSL_N --with-zlib-lib=/usr/local/$ZLIB_N/lib --with-zlib-include=/usr/local/$ZLIB_N/include --shared
make
make test
read -p "test $SSL_N [y/n]: " number
if [ $number != 'y' ]
then
echo "Error"
exit
fi
make install

echo "## add below line to ld.so.conf
/usr/local/$SSL_N/lib
###">>/etc/ld.so.conf
ldconfig -v

ln -s /usr/local/$SSL_N /usr/local/openssl

echo "##config for ssl
export PATH=/usr/local/openssl/bin:"'$PATH'"
###">>/etc/profile
source /etc/profile

openssl version -a

##install openssh

service sshd stop
cp -r /etc/ssh /etc/ssh_old`date +%F`
rpm -qa | grep openssh | xargs rpm -e
cd /opt
tar zxvf /opt/$SSH_N.tar.gz
cd /opt/$SSH_N
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/$SSL_N --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib

make && make install

/bin/cp -r ./contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
chkconfig --add sshd

service sshd restart
ssh -V

##PermitRootLogin prohibit-password
#PermitRootLogin yes
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_old`date +%F`
sed -i '33i PermitRootLogin yes' /etc/ssh/sshd_config
service sshd restart

read -p "test SSH [y/n]: " number
if [ $number != 'y' ]
then
echo "Error"
exit
fi

## config telnet close
sed -i '12c disable = yes' /etc/xinetd.d/telnet

#/etc/xinetd.d/telnet
mv /etc/securetty.bak /etc/securetty
service xinetd restart
echo "test telnet"

centeros 6 远程升级ssl ssh 的shell脚本的更多相关文章

  1. 通过java程序(JSch)运行远程linux主机上的shell脚本

    如果您看完文章之后,觉得对您有帮助,请帮我点个赞,您的支持是我不竭的创作动力! 如果您看完文章之后,觉得对您有帮助,请帮我点个赞,您的支持是我不竭的创作动力! 如果您看完文章之后,觉得对您有帮助,请帮 ...

  2. java连接ssh执行shell脚本

    在liunx上写了一个shell脚本,想通过java去调用这个shell脚本,不知道怎么去调用,在网上说使用process这个进程方式,但是我执行机和我shell脚本都不在同一台电脑,老大说java中 ...

  3. ssh 执行 shell脚本执行jps时:-bash: jps: command not found

    转至: https://www.codeleading.com/article/67592908468/ 我构建了hadoop集群.我们一定会写一个shell脚本去每一个节点上去jps,查看每个节点的 ...

  4. java ssh执行shell脚本

    1.添加依赖 com.jcraft:jsch ch.ethz.ganymed:ganymed-ssh2:262 2.获取连接 conn = new Connection(ip, port); conn ...

  5. 【原】Java程序调用远程Shell脚本

    此程序的目的是执行远程机器上的Shell脚本. [环境参数]远程机器IP:192.168.234.123用户名:root密码:rootShell脚本的路径:/home/IFileGenTool/Bak ...

  6. Java实践 — SSH远程执行Shell脚本(转)

    原文地址:http://www.open-open.com/lib/view/open1384351384024.html 1. SSH简介         SSH是Secure Shell的缩写,一 ...

  7. Java实践 — SSH远程执行Shell脚本

    1. SSH简介         SSH是Secure Shell的缩写,一种建立在应用层和传输层基础上的安全协议.SSH在连接和传送过程中会加密所有数据,可以用来在不同系统或者服务器之间进行安全连接 ...

  8. ssh远程调用之shell脚本远程调用应用程序

    1.引子 前几天有一个需求是这样的:本机的shell脚本,通过远程调用另一台机子上的shell脚本,来完成对远程机子上分发的Java程序的执行和其他操作.看上去挺容易,实际上也不难. 第一步:用scp ...

  9. Java SSH远程执行Shell脚本实现(转)

    前言 此程序需要ganymed-ssh2-build210.jar包(下载地址:http://www.ganymed.ethz.ch/ssh2/) 为了调试方便,可以将\ganymed-ssh2-bu ...

随机推荐

  1. python slice 切片

    list,tuple,string,bytes对象可以进行切片处理,生成一个新的这些类的对象. 格式:li[start: stop: step] list切片: >>> li = [ ...

  2. bzoj 4259 4259: 残缺的字符串【FFT】

    和bzoj 4503 https://www.cnblogs.com/lokiii/p/10032311.html 差不多,就是再乘上一个原串字符 有点卡常,先在点值下算最后一起IDFT #inclu ...

  3. bzoj 3262 陌上花开 【CDQ分治】

    三维偏序 首先把所有花按 x一序,y二序,z三序 排序,然后去重,con记录同样的花的个数,然后进行cdq 现在假设有[l.r]区间,其中[l,mid] [mid+1,r],已经递归处理完毕.我们把区 ...

  4. 【CodeForces - 651C 】Watchmen(map)

    Watchmen 直接上中文 Descriptions: 钟表匠们的好基友马医生和蛋蛋现在要执行拯救表匠们的任务.在平面内一共有n个表匠,第i个表匠的位置为(xi, yi). 他们需要安排一个任务计划 ...

  5. 如果没有intelliJ 编译器?

    刚刚是了一晚上的用记事本来写代码,脱离编译器,发现自己完全废了. 写了好多个类,在命令行编译失败,上网查错误,说编码问题, 编码问题解决后,命令行还是编译失败,粘贴到编译器 发现完全是自己代码能力太弱 ...

  6. 9-25模拟赛 By cellur925

    1.相遇(railway.cpp/c/pas)时间限制:1s内存限制:256MB[问题描述]已知我国有 n 座城市,这些城市通过 n-1 条高铁相连.且任意两个城市联通.小 A 想从 x1 号城市出发 ...

  7. cmd - 批量重命名文件

    相信大家或多或少都遇到过类似的情况:从网上下载了好多图片(或者其他的文件),这些图片的名字往往都是些乱七八糟的字母数字的组合,我们想要一次性修改几十张上百张的图片的名字应该怎么办呢? 这里有两种方法, ...

  8. Codeforces 1107E(区间dp)

    用solve(l, r, prefix)代表区间l开始r结束.带了prefix个前缀str[l](即l前面的串化简完压缩成prefix-1个str[l],加上str[l]共有prefix个)的最大值. ...

  9. [洛谷P3512 [POI2010]PIL-Pilots]

    题目链接: 传送门走这里 题目分析: 感觉不是很难啊--不像是蓝题(AC量也不像)恶意评分? 少打了一个+1调了半天,就这样居然还能过60pts?我思路和题解第一篇高度重合是什么鬼啊,太过分了吧本来还 ...

  10. sh 脚本报错

    sh 脚本报错 思路如下: 1.建议按照手工方式运行该脚本. 2.加入-x 方式查看脚本的输出.