加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux 批量升级openssh8.0

发布时间:2020-12-14 00:45:40 所属栏目:Linux 来源:网络整理
导读:updateopenssh.sh ckmsce=/home/updateopenssh.exp????? username=root?????????????????????????????? password=123456 ? ? ? ? ? ? ? ? ? ? ? ?? ????????????????????????????????????? omplist=" 192.167.1.94 192.167.1.95 192.167.1.96 192.167.1.97 "

updateopenssh.sh

ckmsce=/home/updateopenssh.exp?????
username=root??????????????????????????????
password=123456 ? ? ? ? ? ? ? ? ? ? ? ??
?????????????????????????????????????
omplist="
192.167.1.94
192.167.1.95
192.167.1.96
192.167.1.97
"????????????????????????????????????
port=23??????????????????????????????
for ompname in $omplist??????????????
do???????????????????????????????????
? $ckmsce $ompname $username $password $port?????
?????????????????????????????????????
done?????????????????????????????????
#-------------------------------------

?

updateopenssh.exp

#!/usr/bin/expect -f
set date [exec date -d day +‘%Y%m%d‘]
set desthost [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set port [lindex $argv 3]

spawn ssh -D $port [email?protected]$desthost
expect "*assword:*"
send "$passwordr"
expect {
?"*(yes/no)?"
? {
?? send "yesn"
?? expect "*assword:" {send "$passwordn"}
? }
?? "*assword:"
? {
??? send "$passwordn"
? }
? }
expect "*#"
send "scp [email?protected]:/root/openssh-8.0p1.tar.gz /root/ r"
expect {
?"*(yes/no)?"
? {
?? send "yesn"
?? expect "*assword:" {send "$passwordn"}
? }
?? "*assword:"
? {
??? send "$passwordn"
? }
? }
expect "100%"
send "cd /etc/r"
expect "*#"
send "rm -rf ssh_bakr"
expect "*#"
send "cd /etc/init.d/r"
expect "*#"
send "rm -rf sshd_bakr"

expect "*#"
send "mv /etc/ssh /etc/ssh_bakr"
expect "*#"
send "/etc/init.d/sshd /etc/init.d/sshd_bakr"
expect "*#"
send "cd /root/r"
expect "*#"
send "tar xfz openssh-8.0p1.tar.gzr"
sleep 3;
expect "*#"
send "cd /root/openssh-8.0p1/r"
expect "*#"
send -- "./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords--with-pam --with-tcp-wrappers? --with-ssl-dir=/usr/local/ssl --without-hardeningr"
sleep 80;
expect "*#"
send "maker"
sleep 80;
expect "*#"
send "make installr"
sleep 80
expect "*#"
send "yes | cp -a opensshd.init? /etc/init.d/sshdr"
sleep 2;
expect "*#"
send "chmod +x /etc/init.d/sshdr"
sleep 1;
expect "*#"
send "cat /etc/ssh/sshd_config | grep Perr"
sleep 1;
expect "*#"
send "echo? ‘PermitRootLogin yes‘ >> /etc/ssh/sshd_configr"
sleep 1;
expect "*#"
send "chmod +x /etc/init.d/sshdr"
sleep 2;
expect "*#"
send "service sshd restartr"
sleep 2;
expect "*#"
send "service sshd restartr"
sleep 2;
interact

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读