2015/09/25 11:20:52

秘密鍵/公開鍵の作成: ssh-kyegen

ssh-keygen

ssh 認証で利用する鍵(秘密鍵/公開鍵)を生成、管理、変換するコマンド

鍵の作成: ssh-kyegen -t

ssh-keygen -t rsa

コメント付きの場合

ssh-keygen -t rsa1 -C "comment"

鍵の作成 実例

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/foo/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/foo/.ssh/id_rsa.
Your public key has been saved in /home/foo/.ssh/id_rsa.pub.
The key fingerprint is:
2e:cd:9a:62:fe:54:7f:54:71:72:16:9a:04:7b:9e:8d foo@server

以下のファイルが作成される

  • /home/foo/.ssh/id_rsa (秘密鍵)
  • /home/foo/.ssh/id_rsa.pub (公開鍵)

パスフレーズは必要に応じて設定する。コメントも任意で良い。

鍵の finger print の確認: ssh-keygen -l -f id_rsa

$ ssh-keygen -l -f ~/tmp/id_rsa
2048 2e:cd:9a:62:fe:54:7f:54:71:72:16:9a:04:7b:9e:8d /home/foo/.ssh/id_rsa.pub

鍵のパスフレーズ変更: ssh-keygen -p -f id_rsa

$ ssh-keygen -p -f ~/.ssh/id_rsa
Key has comment '/home/foo/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase): ******** 
Enter same passphrase again: ********
Your identification has been saved with the new passphrase.
サイト内検索