Skip to content

Instantly share code, notes, and snippets.

@altmas5
Last active April 10, 2018 23:55
Show Gist options
  • Save altmas5/9f3c7ed75abbb449c303d7993aa4d1e9 to your computer and use it in GitHub Desktop.
Save altmas5/9f3c7ed75abbb449c303d7993aa4d1e9 to your computer and use it in GitHub Desktop.
Generate the Asterisk passwdfile accepted by the Authenticate function
#!/bin/bash
if [ -z "$1" ]
then
echo "Debe recibir el número de códigos a generar como parametro";
exit;
fi
n=$1
for i in $(seq 1 $n)
do
echo "Generando contrasena $i";
random=`/usr/bin/shuf -i 1111-9999 -n 1`;
randomhashed=`echo -n $random | md5sum`;
echo -n "$random:$randomhashed"|rev|cut -c 4-|rev >> passwdfile.txt
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment