LoginSignup
24
24

More than 5 years have passed since last update.

公開鍵をヨリ楽に設置する方法

Last updated at Posted at 2014-02-18

課題

公開鍵を何度も何度も何度も何度も、authorized_keysに入れたり.sshの配下に置いたりするのは結構大変な経験をしてる方もいると思います。chefとかansibleとかあるから、少なくなってきてますが、、、それでもchefをするためのユーザに公開鍵を!みたいなことがあると思います。

(きっと)今まで

各サーバで
$ ssh [SERVER]
$ mkdir /home/[USER]/.ssh
$ cat /tmp/[USER].pub >> /home/[USER]/.ssh/authorized_keys
$ chmod 600 /home/[USER]/.ssh/authorized_keys

これから

remoteサーバから
$ ssh-copy-id -i .ssh/[送信したい].pub [USER]@[SERVER]

補足

ssh-copy-idを複数回実行しても鍵が追記されるのでremoteサーバ側で公開鍵をpoolしておくと便利かもしれないです。

まとめ

セキュアなsshd_configにしていると少し調整が入りますが、サーバがたくさんあったりすると時間短縮になると思います。

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