我使用命令行工具pwgen
来生成密码,因为我喜欢通过命令行标志获得的可重复性sha1
。引用手册页:
-H, --sha1=/path/to/file[#seed]
Will use the sha1's hash of given file and the optional seed to
create password. It will allow you to compute the same password
later, if you remember the file, seed, and pwgen's options used.
ie: pwgen -H ~/your_favorite.mp3#[email protected] gives a list of
possibles passwords for your pop3 account, and you can ask this
list again and again.
WARNING: The passwords generated using this option are not very
random. If you use this option, make sure the attacker can not
obtain a copy of the file. Also, note that the name of the file
may be easily available from the ~/.history or ~/.bash_history
file.
我用它来生成(和检索)密码,如下所示:
pwgen -1cnsy --sha1=/path/to/my/gpg/private-key.asc#[email protected]
唯一的问题是我无法找到一种方法来指定我想要的密码有多少个字符。默认情况下,它会生成 8 个字符的密码,该密码更容易受到暴力破解。
或者,我可以使用apg
,它允许我指定字符数,但我没有看到一种方法可以apg
将文件和字符串作为种子来提供可重复的字符。
有没有办法可以pwgen
生成指定长度的密码?
答案1
Usage: pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]
因此:
pwgen -1cnsy --sha1=/path/to/my/gpg/private-key.asc#[email protected] 42
请注意,它pwgen
会很乐意打印您请求的密码,但超过某个点(由指定文件的熵确定)时,这不会提高安全性。