#!/bin/bash# get current date
currentDate=`date +%Y-%m-%d\ %H:%M:%S`# set user for change pass
operationUser=root
# save new pass to file
fileDir="/home/superroot/allRootPass.txt"# get old pass
oldPass=`tail -n 1 ${fileDir}|awk -F ' -- ''{print $2}'`# create new pass by openssl -- 16
newPass=`openssl rand -base64 16`# mainecho"${newPass}"|passwd --stdin ${operationUser}&&echo"[ ${currentDate} ] -- ${newPass}">>${fileDir}
脚本编写#!/bin/bash# get current datecurrentDate=`date +%Y-%m-%d\ %H:%M:%S`# set user for change passoperationUser=root# save new pass to filefileDir="/home/superroot/allRootPass.txt"# get old passoldPass=`tail -n 1 ${fileDir} | awk -F ' -- ' '{print