I'm using this to set passwords in a script:
usermod -p `mkpasswd -H md5 passwordText` user
I need to create an exception in my script, just in case this command fails. What file contains the encrypted password and how do I reverse the encryption so I can verify it was written to the file correctly?
Edit: I finally found the problem with the line above. The password was allowing symbols that were being interpreted as wildcards on the command line making it appear as if the command itself failed. Nonetheless, it's lead me to new things I'm glad I know now.
Instead of reversing the the shadow- file, why not just do:
You could replace whatever you want in the
if
block, but if a command ever fails forusermod
it'll return a non-zero status.The password is stored in
/etc/shadow
and you can try to confirm it with john the ripper.I am not sure if posting tutorials for john are allowed here, if so I can write one easily enough, but if not a google search will show you how.
Last I looked, John needed a patch, but the bug report on launchpad seemed to indicate that the patch was incorporated into the repos, so I would try the un-patched version first (I know, lazy =) ).
Short of john,
su - test_user
-> enter password.Brief tutorial on john the ripper:
Install john
Prepare the working database (I made a user "test" with a weak password for this example).
Run john
As you can see, john cracked the weak password in 0.03 seconds, my user password is too strong for john so I aborted it with Crtl + c
Show the password
Here we see the user "test" with the password "testing"
test@ufbt:/home/test