Last active
September 4, 2020 14:36
-
-
Save kalebo/e727e2bb454bbf15bfc04903a0ced4f6 to your computer and use it in GitHub Desktop.
Automates the first few steps of creating a user and poplating it with an allowed ssh key from gitlab
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
NEWUSER=$1 | |
USERFULLNAME=$2 | |
PASS=$(diceware) | |
adduser --disabled-password --gecos "$USERFULLNAME,,," $NEWUSER | |
echo "$NEWUSER:$PASS" | chpasswd | |
sudo -u $NEWUSER -s <<USERSCRIPT | |
mkdir -p ~/.ssh | |
umask 177 | |
curl -o ~/.ssh/authorized_keys https://gitlab.coreform.com/$NEWUSER.keys | |
echo $PASS > ~/temp.password | |
USERSCRIPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment