git4pipi/getNewUser.sh

22 lines
410 B
Bash
Executable File

#!/bin/bash
if [ $# -lt 1 ]
then
read -p "L'utilisateur: " user
else
user=$1
fi
if [ $# -lt 2 ]
then
read -p "Le nom du pc: " pc
else
pc=$2
fi
otpHex=`openssl rand -hex 32`
otpBase32=`oathtool -v $otpHex | grep "Base32" | cut -d " " -f 3`
qrUrl="otpauth://totp/$pc:$user@git.bernard.com.de?digits=6&issuer=Bernard&secret=$otpBase32"
qrencode -t UTF8 $qrUrl
echo "Le code hexadecimal secret est $otpHex"