利用openssl生成若干随机密码,非常简单,实现如下。 

 
  
  1. #!/bin/bash 
  2. #Creat Rand passowd by openssl. 
  3. echo -n "How many rand passwd do you need: ";read var1    #输入生成密码个数。 
  4. echo -n "Input the longth of passwd: ";read var2          #输入密码长度。 
  5. for ((i=1;i<=$var1;i=i+1)) 
  6.   do 
  7.     openssl rand $var2 -base64 >> Randpasswd.txt          #生成密码并保存到Randpasswd.txt文件中。 
  8.   done 
  9. echo "Creat Rand passwod successfully in "Randpasswd.txt"."