Shell 脚本远程批量执行命令
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shell 脚本远程批量执行命令相关的知识,希望对你有一定的参考价值。
#! /usr/bin/expect set IP 10.91.96. ###### 网段 set time 30 set username root #####for {set ip 11} {$ip<=50} {incr ip} { ###### 大于等于11小于等于50,如果IP有规律可用。 foreach ip {81 82 83 84 86 87 88 89 91 92 93 94 96 97 98 99} { ######IP spawn ssh -p 6122 [email protected]$IP$ip expect { "(yes/no)?" { send "yes\r"; exp_continue } "Password:" { send "[email protected]\r" } ###### root密码 } 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 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
本文出自 “汜水流年_” 博客,请务必保留此出处http://timefiles.blog.51cto.com/8475652/1882130
以上是关于Shell 脚本远程批量执行命令的主要内容,如果未能解决你的问题,请参考以下文章