Created
April 25, 2021 00:20
-
-
Save bitdivine/8ae40afd59a26c0899e0619c508a67d5 to your computer and use it in GitHub Desktop.
Create a user with sudo and ssh 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
set -eux | |
user="$1" | |
github_user="$2" | |
mkdir -p "users" | |
rm -fr "users/${user}" | |
cp -R /etc/skel "users/${user}" | |
mkdir -p "users/${user}/.ssh" | |
chmod 700 "users/${user}/.ssh" | |
curl --fail "https://github.com/${github_user}.keys" > "users/${user}/.ssh/authorized_keys2" | |
chmod 600 "users/${user}/.ssh/authorized_keys2" | |
sudo useradd -m --skel "users/${user}" -G sudo "$user" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment