LoginSignup
2
2

More than 5 years have passed since last update.

GitHubアカウントに登録している公開鍵からauthorized_keysを生成する

Last updated at Posted at 2014-01-10

内容

GitHubアカウントに登録している公開鍵は https://github.com/${user_name}.keys から取得できるので、それをローカルのauthorized_keysにコピーする。複数人対応。

authorized_keys.cron
#!/bin/sh

GITHUB_USERS=(mochi udon soba)
DESTINATION=~/.ssh/authorized_keys

rm -rf "$DESTINATION"

for user in ${GITHUB_USERS[@]}
do
  curl -L https://github.com/${user}.keys >> "$DESTINATION"
done

chmod 600 "$DESTINATION"

上のスクリプトをサーバーの/etc/cron.daily辺りにでも置いておけば、後は定期的にGitHubアカウントに登録している公開鍵を取得してサーバーのauthorized_keysを更新してくれる。

業務用で使うのは怖いが、個人用途のサーバーなら結構便利である。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2