LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

mkpasswd

generates password hashes suitable for /etc/shadow or similar uses

TLDR

Generate password hash
$ mkpasswd [password]
copy
Generate with specific method
$ mkpasswd -m sha-512 [password]
copy
Generate with salt
$ mkpasswd -S [salt] [password]
copy
Generate random password
$ mkpasswd -l [16]
copy
List available methods
$ mkpasswd -m help
copy

SYNOPSIS

mkpasswd [options] [password]

DESCRIPTION

mkpasswd generates password hashes suitable for /etc/shadow or similar uses. It can use various hashing algorithms and optionally generate random passwords.The tool is useful for creating encrypted passwords for system configuration files and automated provisioning.

PARAMETERS

-m method

Hash method (sha-512, sha-256, md5, des).
-S salt
Specify salt value.
-R rounds
SHA rounds count.
-l length
Generate random password of length.
-s, --stdin
Read password from stdin.
-5
Use MD5 (shortcut).
-P fd
Read password from file descriptor.

CAVEATS

Different versions have different options. whois package version differs from expect package. Strong methods recommended (sha-512). Avoid storing plaintext passwords.

HISTORY

mkpasswd exists in multiple implementations. The whois package version is common on Debian/Ubuntu, while others may have the expect package version. Both provide password hashing but with different options.

SEE ALSO

passwd(1), openssl(1), crypt(3), chpasswd(1)

Copied to clipboard
Kai