以前のリビジョンの文書です
====== sshの鍵認証設定 ====== ---- 自分のPC(クライアント)から他のPC(サーバー,namae@hostname)に対して * パスワード入力無しでssh login * パスワード入力無しでscpでファイル転送 * パスワード入力無しでsshでcommand送信 などしたいとする。 ==== 手順0 ==== はじめに、双方で~/.ssh/ を作成、permissionを700にしておく。\\ ---- ==== 手順1 ==== クライアント側で鍵を作る。 クライアント側のPCで''ssh-keygen''を実行 <code> $ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/hoge/.ssh/id_rsa): <-鍵のファイルの名前を聞かれるので入力 Enter passphrase (empty for no passphrase): <-パスフレーズを聞かれるので入力(空のままEnterでも良い) Enter same passphrase again: <-パスフレーズ再入力 Your identification has been saved in /home/hoge/.ssh/id_rsa. <- 秘密鍵を作成 Your public key has been saved in /home/hoge/.ssh/id_rsa.pub. <-公開鍵を作成 The key fingerprint is: ..... </code> これで、秘密鍵/home/hoge/.ssh/id_rsa と公開鍵/home/hoge/.ssh/id_rsa.pub が作成される。\\ 公開鍵の方をサーバーに渡す。 <code> $ scp /home/hoge/.ssh/id_rsa.pub namae@hostname:~/.ssh/ </code> ---- ==== 手順2 ==== サーバー側で設定を行う。\\ <code> $ ssh namae@hostname # login ### 以下サーバー側 $ cd ~/.ssh/ $ cat id_rsa.pub >> authorized_keys # 公開鍵情報をauthorized_keysにmerge $ rm id_rsa.pub # もういらないので削除 </code> ✳︎ authorized_keysのpermissionは600にしておく '' chmod 600 ~/.ssh/authorized_keys '' ---- ==== 手順3 ==== クライアント側に戻って設定。\\ クライアント側の~/.ssh/config に以下のように記述 <code> </code>