I need to manually edit /etc/shadow
to change the root password inside of a virtual machine image.
Is there a command-line tool that takes a password and generates an /etc/shadow
compatible password hash on standard out?
linuxpasswordshadow
I need to manually edit /etc/shadow
to change the root password inside of a virtual machine image.
Is there a command-line tool that takes a password and generates an /etc/shadow
compatible password hash on standard out?
Best Answer
You can use following commands for the same:
Method 1 (md5, sha256, sha512)
Note: passing
-1
will generate an MD5 password,-5
a SHA256 and-6
SHA512 (recommended)Method 2 (md5, sha256, sha512)
The option
--method
acceptsmd5
,sha-256
andsha-512
Method 3 (des, md5, sha256, sha512)
As @tink suggested, we can update the password using
chpasswd
using:Or you can use the encrypted password with
chpasswd
. First generate it using this:Then later you can use the generated password to update
/etc/shadow
:The encrypted password we can also use to create a new user with this password, for example: