Linux password policy — setting random password

Time:2020-8-1
#!/bin/bash
 # @Author: HanWei
 # @Date:   2020-02-14 18:51:37
 # @Last Modified by:   HanWei
 # @Last Modified time: 2020-02-14 18:51:37
 # @E-mail: [email protected]
 #################################################
 : 'script function description:
     1. Change the password regularly
     2. Use random password to set password
     3. Send the password to the designated email account
     4. Use method execution script + user name as parameter
 '
 ##################################################    
 date=`date`
 hostname=`hostname`    
 passwd=`openssl rand -base64 16`
 echo $passwd >> passwd.txt
 chattr +a passwd.txt
 user=$1
 echo ${passwd} | passwd --stdin $user
 Echo "passwd is ${passwd} for $user" | mail - s "$date $host name password change notification" Han_ wei_ [email protected]