#! /usr/bin/expectip_array = $ (cat /tmp/ip.txt) username = rootfor ip in ${ip_array[*]} { ##### #IPspawn ssh -p 6122 [email protected]$ $ipexpect {"(yes/ NO)? " { send "yes\r"; exp_continue } "Password:" { send "[email protected]\r " } ###### root password }expect " *# "send " cp /etc/login.defs /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&nbSp 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/1882242
Shell script Remote Batch execution command