linux 批量升级openssh8.0

linux 批量升级openssh8.0,第1张

概述updateopenssh.sh ckmsce=/home/updateopenssh.exp      username=root                               password=123456                                                                omplist=" 192.167.1.94 1

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 "$password\r" expect {
 "*(yes/no)?"
  {
   send "yes\n"
   expect "*assword:" {send "$password\n"}
  }
   "*assword:"
  {
    send "$password\n"
  }
  }
expect "*#"
send "scp [email protected]:/root/openssh-8.0p1.tar.gz /root/ \r"
expect {
 "*(yes/no)?"
  {
   send "yes\n"
   expect "*assword:" {send "$password\n"}
  }
   "*assword:"
  {
    send "$password\n"
  }
  } expect "100%"
send "cd /etc/\r" expect "*#"
send "rm -rf ssh_bak\r" expect "*#"
send "cd /etc/init.d/\r" expect "*#"
send "rm -rf sshd_bak\r"
expect "*#"
send "mv /etc/ssh /etc/ssh_bak\r" expect "*#"
send "/etc/init.d/sshd /etc/init.d/sshd_bak\r" expect "*#"
send "cd /root/\r" expect "*#"
send "tar xfz openssh-8.0p1.tar.gz\r"
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-hardening\r"
sleep 80;
expect "*#"
send "make\r"
sleep 80;
expect "*#"
send "make install\r"
sleep 80
expect "*#"
send "yes | cp -a opensshd.init  /etc/init.d/sshd\r"
sleep 2; expect "*#"
send "chmod +x /etc/init.d/sshd\r"
sleep 1; expect "*#"
send "cat /etc/ssh/sshd_config | grep Per\r"
sleep 1; expect "*#"
send "echo  \‘PermitRootLogin yes\‘ >> /etc/ssh/sshd_config\r"
sleep 1; expect "*#"
send "chmod +x /etc/init.d/sshd\r"
sleep 2; expect "*#"
send "service sshd restart\r"
sleep 2; expect "*#"
send "service sshd restart\r"
sleep 2; interact 总结

以上是内存溢出为你收集整理的linux 批量升级openssh8.0全部内容,希望文章能够帮你解决linux 批量升级openssh8.0所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1024585.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存