LoginSignup
6
6

More than 5 years have passed since last update.

ネットから自分の公開鍵を取得してauthorized_keysに追加する

Posted at

巷に溢れている例のコマンドの改良版。

HTTP、HTTPS

wget https://github.com/nishimura.keys -O - | awk '{gsub(/^$/,"nishimura@github.com",$3);print}' >> authorized_keys

SSH

ssh example.com 'cat .ssh/id_rsa.pub' | awk '{gsub(/^$/,"nishimura@example.com",$3);print}' >> authorized_keys

awkでコメントが無ければ追加する。あればそのまま。
githubはコメントが無いけれど他のサーバーならあるかもしれないので判別する。

awkperlを使わずにgrepcatで出来ないものか…。

6
6
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
6
6