Last active
April 22, 2024 03:55
-
-
Save takumakei/f39a8f2daf15482fbb381f38aeba1c5c to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# | |
# adduser.sh | |
# | |
# usage: curl -fsSL $URL | bash -s -- <github-user-name> [<user-name>] | |
# | |
set -eux -o pipefail | |
main() { | |
local github="$1" | |
local name="${2:-$github}" | |
cat <<EOF | sudo bash -sx | |
export LC_ALL=C | |
adduser "$name" --gecos "" --disabled-password | |
passwd -d "$name" | |
umask 077 | |
mkdir "/home/$name/.ssh" | |
echo "# https://github.com/$github.keys" >> "/home/$name/.ssh/authorized_keys" | |
curl "https://github.com/$github.keys" >> "/home/$name/.ssh/authorized_keys" | |
chown -R "$name:$name" "/home/$name/.ssh" | |
usermod -aG sudo "$name" | |
usermod -aG docker "$name" | |
EOF | |
} | |
main "$@" |
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
#!/usr/bin/env bash | |
# | |
# adduser.sh | |
# | |
# usage: curl -fsSL $URL | bash -s -- <github-user-name> [<user-name>] | |
# | |
set -eux -o pipefail | |
main() { | |
local github="$1" | |
local name="${2:-$github}" | |
cat <<EOF | sudo bash -sx | |
export LC_ALL=C | |
useradd -c "$github" "$name" | |
passwd -d "$name" | |
umask 077 | |
mkdir "/home/$name/.ssh" | |
echo "# https://github.com/$github.keys" >> "/home/$name/.ssh/authorized_keys" | |
curl "https://github.com/$github.keys" >> "/home/$name/.ssh/authorized_keys" | |
chown -R "$name:$name" "/home/$name/.ssh" | |
usermod -aG sudo "$name" | |
usermod -aG docker "$name" | |
EOF | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage
adduser
useradd