Skip to content

Instantly share code, notes, and snippets.

@nilskoppelmann
Last active August 29, 2015 14:13
Show Gist options
  • Save nilskoppelmann/8bd0a5e90d1f0be21dc2 to your computer and use it in GitHub Desktop.
Save nilskoppelmann/8bd0a5e90d1f0be21dc2 to your computer and use it in GitHub Desktop.
simple password generator
#!/bin/sh
# usage: ./pwdgen.sh [keysize]
keyfile=file
ssh-keygen -t rsa -f $keyfile -b 1024 -N '' -v &> /dev/null
totallinenumbers=$(grep -c ".*" $keyfile)
linenumber=$(echo $(($RANDOM % $(expr $totallinenumbers - 2) + 2 | bc)))
echo $(sed -n $(echo $linenumber)p $keyfile) | fold -w $(echo $1)| cat -b | sort -rn | cut -f2- | tail -1
rm $keyfile $keyfile.pub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment