Last active
December 21, 2015 21:18
-
-
Save elasticdog/6367040 to your computer and use it in GitHub Desktop.
shell function to generate user-specific passwords for cjdns
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
hypepass () { | |
if [[ -z $1 ]]; then | |
echo 'Usage: hypepass <USERNAME>' | |
echo 'Generate a user-specific password for allowing someone to peer with your cjdns host' | |
else | |
desired=64 | |
random=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w $(( ${desired} - ${#1} - 1 )) | head -n 1) | |
echo "{ \"user\": \"${1}\", \"password\": \"${1}:${random}\" }" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment