mkpasswd

Table Of Content

Generating password hash

To generate a pwd hash you can use the command mkpasswd. This will allow you to insert your choosen pwd via stdin after you have excuted the command.

The parameter -s allows you to see what pwd you are typing

$ /usr/bin/mkpasswd -m <method-type> -s

The binary mkpasswd is part of the package whois

mkpasswd sample

# generating hash for shado file:
$ mkpasswd
Password: asdf
x05KuFZ.omI1o

Creating password with differnt methods

sha512

# generating hash for shado file:
$ /usr/bin/mkpasswd -m sha-512 -s
Password: asdf
$6$9ypFRuCiSWdHC9cQ$Ryb8sqLsic8ndvdcVPcHtU6QVRgr1giXNJC9p1gTvxAUzKSXaBv3f/lANfXABo2N1w6UjHEyJ1T76ZhtZFUVk0

yescrypt

Depending on you system version, mkpasswd is using it already as default, otherwiese just specify it

# generating hash for shado file:
$ /usr/bin/mkpasswd -m yescrypt -s
Password: asdf
$y$j9T$D26YR2vn8eIUJmCv6DvZx/$.IIja.dMuH140hgVOrZtkSn6p9SH.iY9zwH0thbKaj2

If you get on your Debian the error Invalid method 'yescript'. you are missing the lib which enables the method for you.

For Debian, you will need to install also the package libpam-pwquality if you are running a system older then Debain 11.