# linux生成随机密码 URL: https://chengjinfang.com/posts/2017/install-passwd/ Author: 程锦方 Date: 2017-08-15 Tags: #linux #note #install Summary: 使用 OpenSSL 或 pwgen 生成随机密码。 ------------------------------------------------------------------------ ## 使用openssl生成随机密码 生成长度为10个字符的随机密码 可以使用man openssl来查看openssl的用户守则 ``` openssl rand -base64 10 ``` ![](https://chengjinfang.com/posts/2017/images/linux/s7.png) ## pwgen 安装 ``` sudo get-apt install pwgen ``` 生成指定数量长度为10个字符串的随机密码 ![](https://chengjinfang.com/posts/2017/images/linux/s8.png) 可用参数 ``` -c 或 --capitalize 在密码中包含至少一个大写字母 -A 或 --no-capitalize 在密码中不包含大写字母 -n 或 --numerals 在密码中包含至少一个数字 -0 或 --no-numerals 在密码中不包含数字 -y 或 --symbols 在密码中包含至少一个特殊字符 -s 或 --secure 生成完全随机的密码 -B 或 --ambiguous 在密码中不包含难于区分的字母,如 0 和 o、1 和 l -h 或 --help 输出帮助信息 -H 或 --sha1=path/to/file[#seed] 使用某个给定文件的 sha1 哈希值来作为随机数的生成种子 -C 按列输出生成好的密码 -1 不按列输出生成好的密码 -v 或 --no-vowels 不使用任何元音字母,以防止生成下流的词语 ``` 参考: https://linux.cn/article-8056-1.html ------------------------------------------------------------------------ Site: https://chengjinfang.com/ · All Index: https://chengjinfang.com/all/ · RSS: https://chengjinfang.com/rss.xml