0% found this document useful (0 votes)
71 views3 pages

Method 1 (md5, Sha256, Sha512)

This document provides three methods for generating encrypted passwords from plaintext passwords on Linux systems: Method 1 uses the openssl passwd command to generate SHA512 encrypted passwords with the -6 flag or specify other hashing algorithms like SHA256 with -5. Method 2 uses the mkpasswd command to generate SHA512 encrypted passwords by default or allow specifying other hashing methods like md5 or sha256 with the --method flag. Method 3 allows updating passwords in /etc/shadow by echoing the encrypted password into chpasswd, or generating encrypted passwords with perl or by setting a password when creating a new user.

Uploaded by

HOD-DIT PSG-PTC
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views3 pages

Method 1 (md5, Sha256, Sha512)

This document provides three methods for generating encrypted passwords from plaintext passwords on Linux systems: Method 1 uses the openssl passwd command to generate SHA512 encrypted passwords with the -6 flag or specify other hashing algorithms like SHA256 with -5. Method 2 uses the mkpasswd command to generate SHA512 encrypted passwords by default or allow specifying other hashing methods like md5 or sha256 with the --method flag. Method 3 allows updating passwords in /etc/shadow by echoing the encrypted password into chpasswd, or generating encrypted passwords with perl or by setting a password when creating a new user.

Uploaded by

HOD-DIT PSG-PTC
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Method 1 (md5, sha256, sha512)

openssl passwd -6 -salt xyz yourpass

Note: passing -1 will generate an MD5 password, -5 a SHA256 and -6 SHA512 (recommended)

Method 2 (md5, sha256, sha512)


mkpasswd --method=SHA-512 --stdin

The option --method accepts md5, sha-256 and sha-512

Method 3 (des, md5, sha256, sha512)


As @tink suggested, we can update the password using chpasswd using:
echo "username:password" | chpasswd

Or you can use the encrypted password with chpasswd. First generate it using this:
perl -e 'print crypt("YourPasswd", "salt", "sha512"),"\n"'

Then later you can use the generated password to update /etc/shadow:
echo "username:encryptedPassWd" | chpasswd -e

The encrypted password we can also use to create a new user with this password, for example:
useradd -p 'encryptedPassWd' username

mkpasswd -m sha-512 -S saltsalt -s <<< YourPass


Method 1- Using mkpasswd
On Ubuntu you need to install whois package to get mkpasswd utility.
root@ansible-controller:~/# apt-get install whois
root@ansible-controller:~/# mkpasswd -m sha-512
Password:
$6$KU2P9m78xF3n$noEN/CV.0R4qMLdDh/TloUplmJ0DLnqi6/cP7hHgfwUu.D0hMaD2sAfxDT
3eHP5BQ3HdgDkKuIk8zBh0mDLzO1
Other Options -
root@ansible-controller:~/# mkpasswd — help
Usage: mkpasswd [OPTIONS]… [PASSWORD [SALT]]
Crypts the PASSWORD using crypt(3).
-m, — method=TYPE select method TYPE
-5 like — method=md5
-S, — salt=SALT use the specified SALT
-R, — rounds=NUMBER use the specified NUMBER of rounds
-P, — password-fd=NUM read the password from file descriptor NUM
instead of /dev/tty
-s, — stdin like — password-fd=0
-h, — help display this help and exit
-V, — version output version information and exit
If PASSWORD is missing then it is asked interactively.
If no SALT is specified, a random one is generated.
If TYPE is ‘help’, available methods are printed.
Method 2- Using openssl
root@ansible-controller:~/# openssl passwd -6
Password:
Verifying — Password:
$6$SX8O9xVd1d/WX2hm$vh9RI2WCnh1BKwmHU2QHX5/ZMwH45zLpVe5v7EykPvjtiNGeYq
je9GH2l/dZruVP0kYyPecJRGz1XfYpLERHh0
Other options -
root@ansible-controller:~/# openssl passwd — help
Usage: passwd [options]
Valid options are:
-help Display this summary
-in infile Read passwords from file
-noverify Never verify when reading password from terminal
-quiet No warnings
-table Format output as table
-reverse Switch table columns
-salt val Use provided salt
-stdin Read passwords from stdin
-6 SHA512-based password algorithm
-5 SHA256-based password algorithm
-apr1 MD5-based password algorithm, Apache variant
-1 MD5-based password algorithm
-aixmd5 AIX MD5-based password algorithm
-crypt Standard Unix password algorithm (default)
-rand val Load the file(s) into the random number generator
-writerand outfile Write random data to the specified file
Hope you like the tutorial. Please let me know your feedback in the response section.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy