読み方のヒント

矢印ボタン(または ← → キー)でページを移動できます。

第1節 SSHの仕組みと鍵

1.3 鍵の組を作る

手元のUbuntuで、鍵の組を作ります。-t ed25519 は、鍵の方式を指定するオプションです。

ssh-keygen -t ed25519 -C "haruto@komorebi-pc"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/haruto/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/haruto/.ssh/id_ed25519
Your public key has been saved in /home/haruto/.ssh/id_ed25519.pub
質問答え方
保存する場所そのままEnter(標準の場所を使う)
パスフレーズ秘密鍵を使うときに聞かれる合言葉。設定を勧める

-C の後ろは、鍵に付ける説明です。誰のどのパソコンの鍵かがわかるように書きます。

作られた2つのファイルを確かめます。

ls -l ~/.ssh
-rw------- 1 haruto haruto 464 Nov  5 13:00 id_ed25519
-rw-r--r-- 1 haruto haruto 100 Nov  5 13:00 id_ed25519.pub

.pub の付いたほうが公開鍵、付いていないほうが秘密鍵です。秘密鍵は、自分だけが読み書きできる 600 になっています。公開鍵の中身は1行の文字です。

cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...(略) haruto@komorebi-pc

4 / 36