Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 516  / 1 Year ago, sat, april 1, 2023, 4:47:36

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.


More From » password

 Answers
5

Instead of reversing the the shadow- file, why not just do:



usermod -p `mkpasswd -H md5 passwordText` user

if [ $? -ne 0 ]; then
echo "Changing password failed!!!!!!"
fi


You could replace whatever you want in the if block, but if a command ever fails for usermod it'll return a non-zero status.


[#40100] Sunday, April 2, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
urnaetted

Total Points: 10
Total Questions: 113
Total Answers: 117

Location: Burundi
Member since Sat, Aug 21, 2021
3 Years ago
;