ユーザ用ツール

サイト用ツール


01_linux:01_net:06_sshd鍵

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
01_linux:01_net:06_sshd鍵 [2014/04/04 07:34] matsui01_linux:01_net:06_sshd鍵 [2015/12/04 03:39] (現在) matsui
行 1: 行 1:
 +====== 06 sshでパスワードなしにログインするには ======
  
 +^ログイン元||
 +|ホスト名|ssh-host01|
 +|IP|192.168.10.20|
 +|ユーザ|hoge2|
 +
 +^リモート側||
 +|ホスト名|ssh-host02|
 +|IP|192.168.10.50|
 +|ユーザ|hoge5|
 +
 +===== ①ログイン元で鍵作成 =====
 +
 +下記で、$HOME/.ssh/ディレクトリに秘密鍵(id_rsa)と公開鍵(id_rsa.pub)が作成される。
 +
 +<color red>※ログイン元(ユーザ:hoge2)のユーザで作成</color>
 +
 +<code console>
 +hoge2@ssh-host01 $ ssh-keygen -t rsa ←RSA暗号方式の鍵を作成
 +Generating public/private rsa key pair.
 +Enter file in which to save the key (/home/nori/.ssh/id_rsa): ←[Enter]キー
 +Enter passphrase (empty for no passphrase): ←パスフレーズを入力
 +Enter same passphrase again: ←同じパスフレーズを入力
 +Your identification has been saved in /home/nori/.ssh/id_rsa.
 +Your public key has been saved in /home/nori/.ssh/id_rsa.pub.
 +The key fingerprint is:
 +f9:81:b6:c7:8f:b9:aa:3e:0e:c6:bd:35:19:a1:1e:06 nori@pandora
 +</code>
 +
 +
 +===== ②リモート側で公開鍵をコピー =====
 +
 +
 +次に、リモート側で、先ほど作成した公開鍵を ~/.ssh/authorized_keysに追加し、パーミッションを600に変更する。
 +
 +<color red>※ログイン元(ユーザ:hoge5)のユーザで作成</color>
 +<code console>
 +hoge5@ssh-host02 $ cat id_rsa.pub >> $HOME/.ssh/authorized_keys
 +hoge5@ssh-host01 $ chmod 600 $HOME/.ssh/authorized_keys
 +</code>
 +
 +
 +===== ③ログイン確認 =====
 +
 +ログイン元(ユーザ:hoge2)から、リモート側(ユーザ:hoge5)へsshし鍵でログインできる事を確認
 +
 +<code console>
 +hoge2@ssh-host01 $ ssh hoge5@[リモート側IP]
 +</code>
 +
 +
 +{{tag>ssh}}