Skip to content

Instantly share code, notes, and snippets.

@aokomoriuta
Last active July 29, 2019 03:08
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 aokomoriuta/e3bcbe7cb36d16a484f53555994278ec to your computer and use it in GitHub Desktop.
Save aokomoriuta/e3bcbe7cb36d16a484f53555994278ec to your computer and use it in GitHub Desktop.
githubに登録されている公開鍵でログインできるユーザーを作る
#/bin/bash
# Usage:
# $ wget "https://gist.githubusercontent.com/aokomoriuta/e3bcbe7cb36d16a484f53555994278ec/raw/useradd_github.sh"
# $ sudo bash useradd_github.sh <username>
echo ${1}
useradd -m -s /bin/bash -p "" ${1}
gpasswd -a ${1} sudo
su ${1} -c "mkdir ~/.ssh \
&& chmod 700 ~/.ssh \
&& cd ~/.ssh \
&& wget https://github.com/${1}.keys \
&& mv ${1}.keys authorized_keys \
&& chmod 600 authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment