首页 > 代码库 > Shell 脚本远程批量执行命令
Shell 脚本远程批量执行命令
#! /usr/bin/expect ip_array = $(cat /tmp/ip.txt) username = root for ip in ${ip_array[*]} { ######IP spawn ssh -p 6122 $username@$$ip expect { "(yes/no)?" { send "yes\r"; exp_continue } "Password:" { send "p@ssw0rdWAS\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 脚本远程批量执行命令
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。