#! /usr/bin/expectset ip 10.91.96. ###### Network Segment Set time 30set username root#### #for {set ip 11} {$ip <=50} {incr ip} { ###### is greater than or equal to 11 less than or equal to 50 if IP is regularly available. foreach ip {81 82 83 84 86 87 88 89 91 92 93 94 96 97 98 99} { ##### #IPspawn ssh -p 6122 [email protected] $IP $ipexpect {"(yes/no)?" { send "yes\r"; exp_continue } "Password:" { send "[email protected]\r " } ###### root Password }expect "*#" send "CP&NBSP;/ETC/LOGIN.DEFS&NBsp;/etc/login.defs.bak\r "send " cp /etc/profile /etc/profile.bak\r "send " cp /etc/ Pam.d/common-password /etc/pam.d/common-password.bak\r "send " sed -i -e '/^PASS_ max_days/' d /etc/login.defs\r "send " sed -i -e '/^pass_min_days/' d /etc/ Login.defs\r "send " sed -i -e '/^pass_warn_age/' d /etc/login.defs\r "send " Cecho pass_max_days 90 >> /etc/login.defs\r "send " echo PASS_MIN_DAYS 5 >> /etc/login.defs\r "send " echo pass_warn_age 7 >> /etc/ Login.defs\r "send " secho pass_min_len 8 >> /etc/login.defs\r "send " Echo tmout=300 >> /etc/profile\r "send " echo password required pam_cracklib.so use_authtok minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1 >> /etc/pam.d/ Common-password\r "expect " *# "send " exit\r " }expect eof
This article is from the "BOM water Year _" blog, please be sure to keep this source http://timefiles.blog.51cto.com/8475652/1882130
Shell script Remote Batch execution command