Tyleo-Scripts/irp-quicksudo
2024-02-18 19:06:30 +01:00

33 lines
1.2 KiB
Text
Executable file

if test -z "$1"
then
USERTARGET=$USER
else
USERTARGET=$1
fi
clear
echo "============================================================"
figlet QuickSudo II
echo "============================================================"
echo "============ https://tyleodev.fr == Open Source ============"
echo "============================================================"
echo "/> User Target : $USERTARGET"
echo "/> This Script disable Password Input when using Sudo SU for the current user or choosen one."
## RANDOM PIN
pincode=$(shuf -i 1-100000 -n 1)
#######################
## CONFIRMATION
echo -n -e "/> Please confirm this action by entering this security PIN Code : ($pincode)"
read -r pinin
if [[ "$pinin" -ne "$pincode" ]]
then
echo -e "!> Pincode $pinin received, there is an error here. Good Bye.${Color_Off}"
echo -e "!> Exiting...${Color_Off}"
exit
fi
echo -e "/> Pincode $pinin received, Accepted.${Color_Off}"
#######################
echo "/> Writing User NOPASSWD to /etc/sudoers.d ..."
echo "$USERTARGET ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USERTARGET-nopasswd
echo "/> Quick Sudo installed for $USERTARGET user. Logoff or TTY Reset may be required for seing the change."