Created
January 11, 2021 05:11
-
-
Save leap0x7b/aede4e9f3b96cf1358023388eaf876d2 to your computer and use it in GitHub Desktop.
Dialog-based password changer script
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
#!/bin/bash | |
## This script made to change your password with TUI dialog | |
## Original script made by NixCraft | |
## https://bash.cyberciti.biz/guide/A_password_box | |
# password storage | |
new=$(tempfile 2>/dev/null) | |
# trap it | |
trap "rm -f $new" 0 1 2 5 15 | |
# get password with the --insecure option | |
dialog --title "Password" \ | |
--insecure \ | |
--passwordbox "Enter your new password" 8 50 2> $new | |
ret=$? | |
# make decison | |
case $ret in | |
0) | |
echo -e "${1-$USER}:$(cat $new)" | sudo chpasswd 2> /dev/null;; | |
*) | |
echo "Canceled.";; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment