批量修改密码的shell/ target=_blank class=infotextkey>shell脚本,完整代码始下:
复制代码 代码如下:
#!/bin/bash
pass=$(mkpasswd -l 8 -d 1 -c 1 -C 1)
echo "${pass}"
log_file=pwd_$(date +%Y-%m-%d).log
while read ip
do
ssh root@${ip} passwd --stdin oracle<<< "${pass}"
if [ $? -eq 0 ]
then
echo -e "$(date "+%Y-%m-%d %H:%M:%S")t${ip}t${pass}tok" >> ${log_file}
else
echo -e "$(date "+%Y-%m-%d %H:%M:%S")t${ip}t${pass}tfail" >> ${log_file}
fi
done<ip_file