Skip to content

Instantly share code, notes, and snippets.

@dpastoor
Last active December 29, 2022 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpastoor/3d9f58bc98b20a7183654d9ff16d6128 to your computer and use it in GitHub Desktop.
Save dpastoor/3d9f58bc98b20a7183654d9ff16d6128 to your computer and use it in GitHub Desktop.
misc user creation
#!/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"
#!/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