linux 批量安装telnet脚本

Posted xl-892694298

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 批量安装telnet脚本相关的知识,希望对你有一定的参考价值。

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 [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 "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脚本的主要内容,如果未能解决你的问题,请参考以下文章

linux12运维企业实战笔录 -- 04 telnet批量多端口

通过linux的shell脚本批量处理交换机配置变更

python批量ssh/telnet远程登录设备

pythontelnet批量连接脚本怎么能多个不同网段连接

服务器批量安装系统 服务器批量管理

linux下SSH服务利用shell脚本实现密钥的批量分发与执行