Shell 脚本远程批量执行命令
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shell 脚本远程批量执行命令相关的知识,希望对你有一定的参考价值。
#! /usr/bin/expect ip_array = $(cat /tmp/ip.txt) username = root for ip in ${ip_array[*]} { ######IP spawn ssh -p 6122 [email protected]$$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/1882242
以上是关于Shell 脚本远程批量执行命令的主要内容,如果未能解决你的问题,请参考以下文章