Last active
January 3, 2016 14:39
-
-
Save rutan/8477626 to your computer and use it in GitHub Desktop.
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 | |
# GitHubの公開鍵をSSH認証用の鍵として登録する子 | |
AUTHORIZED_KEYS_FILE="$HOME/.ssh/authorized_keys" | |
if [ -z $GITHUB_ACCOUNT ]; then | |
GITHUB_ACCOUNT='rutan' | |
fi | |
# 認証鍵の登録 | |
ssh_pub_key=`curl https://github.com/"${GITHUB_ACCOUNT}".keys` | |
if [ ${#ssh_pub_key} -eq 1 ]; then | |
echo '鍵 is 見つからない' | |
exit 1; | |
fi | |
grep_result=`grep "${ssh_pub_key}" "${AUTHORIZED_KEYS_FILE}"` | |
if [ "$ssh_pub_key" = "$grep_result" ]; then | |
echo 'already registered ssh public key' | |
else | |
echo 'register ssh public key' | |
echo "${ssh_pub_key}" >> "$AUTHORIZED_KEYS_FILE" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment