ssh-keygenでssh鍵を作成


利用するコマンド

ssh-keygen -A
  • ssh-keygen
    • sshキーを作成する
    • 作成する場所:/etc/ssh
  • -A
    • キーをすべて作成するオプション
  • 作成する鍵
    • rsa
    • dsa
    • ecdsa
    • ed25519

作成された鍵の確認

ls -l /etc/ssh/*host*
-rw------- 1 root root 1393 Feb 9 10:32 /etc/ssh/ssh_host_dsa_key
-rw-r--r-- 1 root root 610 Feb 9 10:32 /etc/ssh/ssh_host_dsa_key.pub
-rw------- 1 root root 513 Feb 9 10:32 /etc/ssh/ssh_host_ecdsa_key
-rw-r--r-- 1 root root 182 Feb 9 10:32 /etc/ssh/ssh_host_ecdsa_key.pub
-rw------- 1 root root 411 Feb 9 10:32 /etc/ssh/ssh_host_ed25519_key
-rw-r--r-- 1 root root 102 Feb 9 10:32 /etc/ssh/ssh_host_ed25519_key.pub
-rw------- 1 root root 2610 Feb 9 10:32 /etc/ssh/ssh_host_rsa_key
-rw-r--r-- 1 root root 574 Feb 9 10:32 /etc/ssh/ssh_host_rsa_key.pub
  • 4 x 2 = 8ファイルが作られる
    • 4:鍵4種類
    • 2:それぞれに公開鍵と秘密鍵

関連記事紹介

  • Linuxのsshデーモンを起動してTeraterm接続する手順を説明した記事
  • 概要
    • WSL(Linux)にTeraterm接続する手順
    • ssh-keygenを使って下記を生成
    • sshd_configの設定変更(パスワード認証を設定)
    • sshd起動
    • ローカル環境からTeratermを使ってssh接続
    • xclockやxeyesの画面表示

補足

manの抜粋

For each of the key types (rsa, dsa, ecdsa and ed25519) 
for which host keys do not exist, 
generate the host keys with the default key file path, 
an empty passphrase, default bits for the key type, and default comment. 

If -f has also been specified, its argument is used as a prefix to the default path 
for the resulting host key files. 

This is used by system administration scripts to generate new host keys.
  • 4種類のカギを作成:For each of the key types (rsa, dsa, ecdsa and ed25519)


Posted by futa