Created
December 2, 2016 10:26
-
-
Save mmmunk/3630e59b6a791c3243f3b9a88a517e35 to your computer and use it in GitHub Desktop.
Script for validating a Linux password. Method SHA-512 (Type ID 6 - first shadow col) expected.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
L1=`grep $1 /etc/shadow|cut -d ":" -f 2` | |
if [ $L1 ]; then | |
SALT=`echo $L1|cut -d "$" -f 3` | |
L2=`mkpasswd --salt=$SALT --method=sha-512 $2` | |
if [ "$L1" == "$L2" ]; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
else | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment