利用openssl生成若干随机密码,非常简单,实现如下。
- #!/bin/bash
- #Creat Rand passowd by openssl.
- echo -n "How many rand passwd do you need: ";read var1 #输入生成密码个数。
- echo -n "Input the longth of passwd: ";read var2 #输入密码长度。
- for ((i=1;i<=$var1;i=i+1))
- do
- openssl rand $var2 -base64 >> Randpasswd.txt #生成密码并保存到Randpasswd.txt文件中。
- done
- echo "Creat Rand passwod successfully in "Randpasswd.txt"."
转载于:https://blog.51cto.com/xikder/744535