Help us understand the problem. What is going on with this article?

ssh-copy-idで公開鍵を渡す

More than 1 year has passed since last update.

鍵認証による ssh を行おうとすると ssh する元のサーバで公開鍵を生成してそれを ssh 先のサーバに持って行って.ssh/authorized_keysに追記しないといけない。めんどくさいなぁと思っていたんだが、ssh-copy-idというコマンドで簡単にコピーすることができる。

ssh-copy-id の利用

引数にアカウント@接続先ホスト名を指定して実行する。これはssh接続するときと同じ。

~/.ssh/id_rsa.pubを渡す場合
ssh-copy-id ${USER}@${target_host}

-iオプションで任意の公開鍵を指定することもできる

ssh-copy-id -i ${identity_file} ${USER}@${target_host}

いつも使っていた方法

cat ~/.ssh/id_rsa.pub | ssh ${USER}@${target_host} "mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした