Linux/mkpasswd

From Omnia
Revision as of 16:20, 17 October 2022 by Kenneth (talk | contribs) (Created page with "The /etc/shadow password format is set to $id$salt$hashed, The $id is the algorithm used On GNU/Linux as follows: $1$ is MD5 $2a$ is Blowfish $2y$ is Blowfish $5$ is SHA-2...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The /etc/shadow password format is set to $id$salt$hashed, The $id is the algorithm used On GNU/Linux as follows:

$1$ is MD5
$2a$ is Blowfish
$2y$ is Blowfish
$5$ is SHA-256
$6$ is SHA-512

Install mkpasswd:

sudo apt install whois

Usage:

mkpasswd -m [algorithm] [password] [salt]

If you don't specify a salt, one will be generated.

Example:

mkpasswd -m SHA-512 test1234 OXE8gHwh2.nmuwp7
$6$OXE8gHwh2.nmuwp7$lrs3VWJiL9bFG0HRjtSWI3T7hbQOIVOA8GewwM7nPaZKy7TXtiD/pKoEM.pQvR9NNpnZyP2qhCrsvVf1NJEFl/

Note: You can also use the above to compare with and existing password to make sure you know what the password is.

Python example:

import crypt
 
# usage: crypt.crypt("password", "hasing algorithm + salt")
print(crypt.crypt("test1234", "$6$OXE8gHwh2.nmuwp7$"))
 
# sample output: $6$OXE8gHwh2.nmuwp7$lrs3VWJiL9bFG0HRjtSWI3T7hbQOIVOA8GewwM7nPaZKy7TXtiD/pKoEM.pQvR9NNpnZyP2qhCrsvVf1NJEFl/

ref: [1]

ref: [2]