Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #This script was made with OpenVPN via-file in mind
- #Location of the Approved Username/Password File
- USERS="/somefolder/users"
- #Check to see if username and password in the OpenVPN file has any special characters line by line
- #Terminate script if special characters are used
- while IFS= read -r line
- do
- case "$line" in *[!-_a-zA-Z0-9]*) exit 1 ;; esac
- done < "$1"
- Username=`awk 'NR==1' "$1"`
- Password=`awk 'NR==2' "$1"`
- HASHPASS=`echo -n "$Username$Password" | md5sum | sed s'/ -//'`
- i=0
- while [ $i -lt 10 ]; do
- HASHPASS=`echo -n $HASHPASS$HASHPASS | md5sum | sed s'/ -//'`
- i=`expr $i + 1`
- done
- if grep -q "$Username:$HASHPASS" $USERS; then
- echo "User Authenticated."
- exit 0
- fi
- echo "Login credentials failed."
- exit 1
Add Comment
Please, Sign In to add comment