← 返回命令列表

Linux command

makepasswd 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Generate random password

makepasswd

Generate multiple passwords

makepasswd --count [5]

Generate password of specific length

makepasswd --chars [16]

Generate with specific character set

makepasswd --string '[A-Za-z0-9!@#]'

Generate a crypted password

makepasswd --crypt-md5

Use a fixed random seed

makepasswd --randomseed [42] --count [3]

Specify minimum and maximum length

makepasswd --minchars [8] --maxchars [12]

说明

makepasswd generates random passwords suitable for user accounts. It uses /dev/urandom for randomness, producing cryptographically suitable output. By default, it generates a single password of reasonable length using letters and digits. The string option customizes the character set for specific password policies. The crypt options produce password hashes suitable for /etc/shadow. MD5 crypt produces hashes starting with $1$, compatible with modern systems. DES crypt is legacy and limited to 8 characters. Batch generation with count is useful for provisioning multiple accounts. Combined with proper length and character requirements, it meets most password policies. For scripting, passwords output one per line. When combined with crypt, both cleartext and hash appear for reference.

参数

--count _N_
Generate N passwords.
--chars _N_
Password length.
--minchars _N_
Minimum length.
--maxchars _N_
Maximum length.
--string _CHARS_
Characters to use.
--crypt
Output DES-crypted password.
--crypt-md5
Output MD5-crypted password.
--clearfrom _FILE_
Read cleartext from file.
--cryptsalt _N_
Salt for crypt.
--randomseed _N_
Seed the random generator with _N_ (use 0 for true randomness, a fixed value for reproducibility).
--rerandom _N_
Re-seed the random generator every _N_ passwords.
--repeatpass _N_
Emit each generated password _N_ times (useful with --crypt to pair cleartext with hash).
--nocrypt
Skip cryptographic hashing and output the cleartext only.
--verbose, --noverbose
Toggle explanatory output.

FAQ

What is the makepasswd command used for?

makepasswd generates random passwords suitable for user accounts. It uses /dev/urandom for randomness, producing cryptographically suitable output. By default, it generates a single password of reasonable length using letters and digits. The string option customizes the character set for specific password policies. The crypt options produce password hashes suitable for /etc/shadow. MD5 crypt produces hashes starting with $1$, compatible with modern systems. DES crypt is legacy and limited to 8 characters. Batch generation with count is useful for provisioning multiple accounts. Combined with proper length and character requirements, it meets most password policies. For scripting, passwords output one per line. When combined with crypt, both cleartext and hash appear for reference.

How do I run a basic makepasswd example?

Run `makepasswd` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --count _N_ do in makepasswd?

Generate N passwords.