Skip to content

Instantly share code, notes, and snippets.

@sudocurse
Created June 26, 2018 17:58
Show Gist options
  • Save sudocurse/e7433f923cfc8b8641c5bff05b871611 to your computer and use it in GitHub Desktop.
Save sudocurse/e7433f923cfc8b8641c5bff05b871611 to your computer and use it in GitHub Desktop.
sudo access on wheel-supported systems
# 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