批量重置用户密码
2015-11-17 20:30
417 查看
需要root 免密到需要修改的机器 #!/bin/bash #2015-11-11 #reset root passwd @by xbzy User="$1" LogFile="modify_passwd_" function Change_passwd() { IP=$1 _passwd=$(head /dev/urandom |md5sum |head -c 16) ssh -o ConnectTimeout=15 -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no $IP "echo '$User:${_passwd}' | chpasswd" test $? -ne 0 && echo -e "\e[1;31mPassword modify Failed\e[0m" &&exit -2||echo -e "Password modify\e[1;32m [ success ]\e[0m\n" sed -i "/$IP/d" $LogFile$User echo "$(date +%F_%H-%M-%S) Host:$IP User:$User PASS:${_passwd}" |tee -a $LogFile$User } function More_IP() { #_passwd=$(head /dev/urandom |md5sum |head -c 16) List="$1" for i in `cat $List` do echo -e "########$i\n" # Change_passwd $i ${_passwd} Change_passwd $i done } function One_IP() { # _passwd=$(head /dev/urandom |md5sum |head -c 16) Change_passwd $1 } function Mesage() { echo -e "\e[1;32mUsage:sh $0 username IP :sh $0 username -f iplist\e[0m" exit -1 } if [ $# -ne 2 ] && [ $# -ne 3 ];then Mesage fi if [ "$2" == "-f" ] && [ $# -eq 3 ];then More_IP $3 elif [ $# -eq 2 ];then echo $2 | grep -E "([a-z]+\-)([a-z]+\-)([a-z]+[0-9]+\.)([a-z])|([0-9]+\.)([0-9]+\.)([0-9]+\.)[0-9]+" && One_IP $2||Mesage else Mesage fi
相关文章推荐
- 重置动易(SiteWeaver 6.5)的管理员密码的代码
- N点主机管理系统重置密码方法(在线修改密码)
- 使用UC_KEY可重置论坛(除uid为1的)任意用户的密码
- 重置mysql的root密码
- MYSQL复原ROOT用户密码
- IOS - 注册手机号和重置密码请求函数
- 修改Mysql密码
- mysql 密码重置
- 创建一个UI输入框,以向一个重置密码的powershell脚本输入参数
- AD 重置密码完整脚本 推荐
- mysql数据库密码重置的方法
- windows下mysql忘记root密码的解决方法
- Netscaler重置密码的方法
- MariaDB/Mysql 忘记密码 重置root密码
- 织梦网站后台登录密码重置
- php中密码的加密处理及安全措施
- Linux中mysql的root密码重置
- Centos7重置root密码
- Centos7完美重置root密码(极简步骤,附图)
- 重置Jenkins用户权限和密码