How to reset a user password without using passwd command?

Commonly in Unix systems, we have to use passwd command to reset a users password.

Example, How to reset a password for the user bob in a common method using passwd command.

[root@server~]# passwd bob
Changing password for user bob.
Enter new password:
Re-type new password:
passwd: all authentication tokens updated successfully.
[root@server~]#

Now, How to reset a password for the user bob without using passwd command. There is a another way to reset a user password by using usermod command.

Initially you need generate the encrypted password by using a command grub-crypt. The SHA 512 is an algorithm which is commonly used in Unix systems.

Once you have entered the password twice, the grub-crypt command will generate the encrypted password.

[root@server~]# grub-crypt --sha-512
Password:
Retype password:
$6$qwPi1nKvWd/ggNe/$8LktAgTUz6GhxxVlCq8T3o3l2hYzSFDG032iplz10YIr7mh0yU1LGixhpiqQvWjIoBuNgNEHaDs.uXsu6qbE9/
[root@server~]#

Now copy the encrypted password and use the same in usermod command to reset a password for a user bob. See below,

[root@server~]# usermod -p '$6$qwPi1nKvWd/ggNe/$8LktAgTUz6GhxxVlCq8T3o3l2hYzSFDG032iplz10YIr7mh0yU1LGixhpiqQvWjIoBuNgNEHaDs.uXsu6qbE9/' bob

Related posts

Leave a Comment