Skip to content

Instantly share code, notes, and snippets.

@tosin2013
Created June 27, 2021 19:01
Show Gist options
  • Save tosin2013/385054f345ff7129df6167631156fa2a to your computer and use it in GitHub Desktop.
Save tosin2013/385054f345ff7129df6167631156fa2a to your computer and use it in GitHub Desktop.
Configure Sudo user
#!/bin/bash
set -xe
if [ -z $1 ];
then
echo "Please pass user to be created."
echo "USAGE: $@ username"
exit 1
fi
USER=${1}
if getent passwd ${USER} > /dev/null 2>&1; then
echo "${USER} exists"
else
echo "${USER} does not exist"
useradd ${USER}
passwd ${USER}
fi
usermod -aG wheel ${USER}
echo "${USER} ALL=(root) NOPASSWD:ALL" | tee -a /etc/sudoers.d/${USER}
chmod 0440 /etc/sudoers.d/${USER}
@tosin2013
Copy link
Author

curl -OL https://gist.githubusercontent.com/tosin2013/385054f345ff7129df6167631156fa2a/raw/b67866c8d0ec220c393ea83d2c7056f33c472e65/configure-sudo-user.sh
chmod +x configure-sudo-user.sh
./configure-sudo-user.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment