Last active
December 29, 2022 18:57
-
-
Save dpastoor/3d9f58bc98b20a7183654d9ff16d6128 to your computer and use it in GitHub Desktop.
misc user creation
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 | |
set -eux | |
USER=$1 | |
PW=$2 | |
if id -u "$USER" &>/dev/null; then | |
echo "$USER already created, going to next..." | |
exit 0; | |
fi | |
useradd $USER -s /bin/bash && echo "$USER:$PW" | chpasswd | |
mkdir /home/$USER && chown $USER:$USER /home/$USER | |
usermod -a -G rstudio-admins $USER | |
su $USER -c "mkdir ~/.ssh" | |
su $USER -c "curl -o /home/$USER/.ssh/authorized_keys https://github.com/$USER.keys" | |
su $USER -c "chmod 0600 /home/$USER/.ssh/authorized_keys" |
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 | |
set -ex | |
group="rstudio-admins" | |
groupadd --force "${group}" | |
mkdir -p "/etc/sudoers.d" | |
echo "%${group} ALL=(ALL) NOPASSWD:ALL" >"/etc/sudoers.d/${group}-sudoers" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment