Created
June 26, 2018 17:58
-
-
Save sudocurse/e7433f923cfc8b8641c5bff05b871611 to your computer and use it in GitHub Desktop.
sudo access on wheel-supported systems
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
# add user to the sudo users group | |
sudo usermod $1 -G wheel | |
# generate a 16 byte key and print it | |
key=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1` | |
echo $key | |
# set the users password to that key and expire it so they have to change it when they login | |
sudo sh -c "echo $key | passwd --stdin $1" | |
sudo passwd -e $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment