Created
June 27, 2021 19:01
-
-
Save tosin2013/385054f345ff7129df6167631156fa2a to your computer and use it in GitHub Desktop.
Configure Sudo user
This file contains hidden or 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 | |
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} |
Author
tosin2013
commented
Jun 27, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment