Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/init.php on line 542
ja:network:sshkey [GiriWiki]

ユーザ用ツール

サイト用ツール


ja:network:sshkey

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
ja:network:sshkey [2015/06/10 20:34]
kota [sshの鍵認証設定]
ja:network:sshkey [2015/06/14 02:49] (現在)
kota [手順1]
ライン 10: ライン 10:
   * パスワード入力無しでsshでcommand送信   * パスワード入力無しでsshでcommand送信
 などしたいとする。 などしたいとする。
 +
 +==== 手順0 ====
 +はじめに、双方で~/​.ssh/​ を作成、permissionを700にしておく。\\
 +
 +
 +----
  
 ==== 手順1 ==== ==== 手順1 ====
ライン 19: ライン 25:
 Generating public/​private rsa key pair. Generating public/​private rsa key pair.
 Enter file in which to save the key (/​home/​hoge/​.ssh/​id_rsa):​ <​-鍵のファイルの名前を聞かれるので入力 Enter file in which to save the key (/​home/​hoge/​.ssh/​id_rsa):​ <​-鍵のファイルの名前を聞かれるので入力
-Enter passphrase (empty for no passphrase):​           <​-パスフレーズを聞かれるので入力(空のままEnterでも良い) +Enter passphrase (empty for no passphrase):​           <​-パスフレーズを聞かれる(空のままEnter) 
-Enter same passphrase again:                   <​-パスフレーズ再入力+Enter same passphrase again:                   <​-パスフレーズ再入力(空のままEnter)
 Your identification has been saved in /​home/​hoge/​.ssh/​id_rsa. <- 秘密鍵を作成 Your identification has been saved in /​home/​hoge/​.ssh/​id_rsa. <- 秘密鍵を作成
 Your public key has been saved in /​home/​hoge/​.ssh/​id_rsa.pub. <​-公開鍵を作成 Your public key has been saved in /​home/​hoge/​.ssh/​id_rsa.pub. <​-公開鍵を作成
ライン 35: ライン 41:
 ---- ----
  
 +==== 手順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 ''​
 +
 +
 +また、/​etc/​ssh/​sshd_config を編集。\\
 +以下についてコメントアウトを解除して、activate
 +<​code>​
 +RSAAuthentication yes
 +PubkeyAuthentication yes
 +AuthorizedKeysFile ​    ​.ssh/​authorized_keys
 +</​code>​
 +
 +----
 +==== 手順3 ====
 +クライアント側に戻って設定。\\
 +クライアント側の~/​.ssh/​config に以下のように記述
 +<​code>​
 +HOST hoge                  ​
 +     ​HostName hostname ​    
 +     User namae             
 +     ​IdentityFile ~/​.ssh/​hoge_rsa ​ # 秘密鍵のファイルを指定
 +</​code>​
 +
 +こうしておけば
 +''​
 +$ ssh hoge
 +''​
 +でパスワード認証無しでloginできる。
  
 +✳︎この設定がなくとも
 +''​
 +$ ssh -i ~/​.ssh/​id_rsa namae@hostname
 +''​
 +でloginできる
ja/network/sshkey.1433968486.txt.gz · 最終更新: 2015/06/10 20:34 by kota