码迷,mamicode.com
首页 > Windows程序 > 详细

定时修改Windows密码

时间:2019-04-23 14:18:55      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:datetime   new   dos   amp   sdc   expect   txt   install   tab   

yum -y install mailx expect

cat /tools/pass/pass.sh

#!/bin/env bash

datetime=date +%Y-%m-%d" "%H":"%M
for user in awk ‘{print $1}‘ /tools/pass/user_list;do
passwd=mkpasswd -d 5 -s 0 -l 20
#ansible windows -m win_command -a "net user $user $passwd"
ansible winserver -m win_command -a "net user $user $passwd"
email=grep $user /root/tools/pass/mail_list| awk ‘{print $2}‘
echo $passwd |mail -s "$datetime new windos system $user passwd" $email
echo $passwd $user >> $(date +%Y-%m-%d"-"%H":"%M).txt

done

cat /tools/pass/user_list

user1 aa@qq.com
user2 bb@qq.com
user3 cc@qq.com

cat /etc/mail.rc

set bsdcompat

set from="ee@qq.com"
set smtp=smtp.qq.com
set smtp-auth-user=ee@qq.com
set smtp-auth-password=ypshshv3b1uadfg4

crontab -l

0 2 sun [ $(date +%d) -le 07 ] && /bin/bash /tools/pass/pass.sh

定时修改Windows密码

标签:datetime   new   dos   amp   sdc   expect   txt   install   tab   

原文地址:https://blog.51cto.com/research/2383155

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!