Last active
July 29, 2019 03:08
-
-
Save aokomoriuta/e3bcbe7cb36d16a484f53555994278ec to your computer and use it in GitHub Desktop.
githubに登録されている公開鍵でログインできるユーザーを作る
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
#/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