码迷,mamicode.com
首页 > Web开发 > 详细

linux 批量安装telnet脚本

时间:2019-06-13 20:47:57      阅读:337      评论:0      收藏:0      [点我收藏+]

标签:pam   pass   passwd   exit   serve   word   count   res   tar   

install_telnet.sh

explujing=/home/install_telnet.exp     
username=root                              
passwd=123456                       
                                     
iplist="
192.167.1.1
192.167.1.2
192.167.1.3
                     
"                                    
port=23                              
for ip in $iplist              
do                                   
  $explujing $ip $username $passwd $port     
                                     
done                                 
#-------------------------------------

 

install_telnet.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 $username@$desthost
expect "*assword:*"
send "$password\r"
expect {
 "*(yes/no)?"
  {
   send "yes\n"
   expect "*assword:" {send "$password\n"}
  }
   "*assword:"
  {
    send "$password\n"
  }
  }
expect "*#"
send "cd /home/Packages/\r"
expect "*#"
send -- "rpm -ivh telnet-server-0.17-47.el6_3.1.x86_64.rpm\r"
sleep 3;
expect "*#"
send -- "rpm -ivh telnet-0.17-47.el6_3.1.x86_64.rpm\r"
sleep 3;
expect "*#"
send -- "rpm -ivh xinetd-2.3.14-38.el6.x86_64.rpm\r"
sleep 3;
expect "*#"
send  "cd /etc\r"
expect "*#"
send  "sed -i \"s/\‘pts/0\‘/\‘#pts/0\‘/g\" /etc/securetty\r"
expect "*#"
send  "sed -i \"s/\‘pts/1\‘/\‘#pts/1\‘/g\" /etc/securetty\r"
expect "*#"
send  "mv securetty securetty_bak\r"
expect "*#"
send  "sed -i \"s/yes/no/g\" /etc/xinetd.d/telnet\r"
expect "*#"
send  "sed -i \"s/account    required     pam_nologin.so/#account    required     pam_nologin.so/g\" /etc/pam.d/login\r"
expect "*#"
send  "cd /root/\r"
expect "*#"
send  "chkconfig  telnet on\r"
expect "*#"
send  "service xinetd restart\r"
sleep 2;
expect "*#"
send  "service xinetd restart\r"
sleep 2;
expect "*#" 

send "exit\r"

interact

 

linux 批量安装telnet脚本

标签:pam   pass   passwd   exit   serve   word   count   res   tar   

原文地址:https://www.cnblogs.com/xl-892694298/p/11018749.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!