Skip to content

Instantly share code, notes, and snippets.

@michilu
Created December 20, 2019 05:00
Show Gist options
  • Save michilu/931d636c143b5af612aaf44fbc45ad28 to your computer and use it in GitHub Desktop.
Save michilu/931d636c143b5af612aaf44fbc45ad28 to your computer and use it in GitHub Desktop.
create_user.sh
#!/bin/bash
set -o errexit
set -o xtrace
set -o nounset
USER=$1
id $USER\
&& userdel -r $USER
useradd -m -s /bin/bash -g operator --password $USER $USER
mkdir -p /home/${USER}/.ssh
cd /home/${USER}
touch .ssh/authorized_keys
curl https://github.com/${USER}.keys > .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
chown -R ${USER}:operator .ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment