首页 > 代码库 > 修改用户密码脚本

修改用户密码脚本

#!/bin/bash

CH () {

read -p "Enter the user name:" NA

[ $NA == n ] && exit 1


if [ "$(/bin/grep "^$NA" /etc/passwd)" == "" ];then

   echo "The user $NA not find"

   CH

fi


a=(a b c d e f g h k l m n A B C D E F G H I J K L M N O P Q X Y Z R S Q P 2 3 4 5 6 7 8 9)

for ((i=0;i<10;i++));do

         echo -n ${a[$RANDOM % ${#a[@]}]} >> passwd.txt

done

PA=`cat passwd.txt`

echo ‘‘ > passwd.txt


echo $PA | passwd --stdin $NA &>/dev/null

echo $NA $PA >> passwd_123.txt

CH

}

CH


本文出自 “运维之道” 博客,请务必保留此出处http://lrtao2010.blog.51cto.com/10425744/1870137

修改用户密码脚本