$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Generating public/private rsa key pair.
Enter file inwhich to save the key (/home/xxxx/.ssh/id_rsa): # ⏎ キーのみを入力
Created directory '/home/xxxx/.ssh'.
Enter passphrase (empty for no passphrase): # ⏎ キーのみを入力
Enter same passphrase again: # ⏎ キーのみを入力
Your identification has been saved in /home/xxxx/.ssh/id_rsa
Your public key has been saved in /home/xxxx/.ssh/id_rsa.pub
: # 以下省略
作成する鍵のビット数を指定します。
RSA の場合、推奨は 2048 bit 以上。今回は 4096 bit を指定。
RSA 512 bit 鍵は既に解読され、 RSA 1024 bit 鍵も危険です。
ssh - Remote PC でコマンドを実行する
ssh - Remote PC にログインする
ネットワーク上の他の PC の IP アドレスを指定してログインします。
今回は自分自身を指す 127.0.0.1 を指定します。
初めての接続先は、接続確認があります。 yes で接続を続行します。
Local-PC $ ssh 127.0.0.1
The authenticity of host '127.0.0.1 (127.0.0.1)' can’t be established.
ECDSA key fingerprint is SHA256:xxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])? # yes を入力
Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts.
Welcome to ...
Remote-PC $ # Remote PC でコマンド入力ができます
exit - Shell を終了する
Local-PC $ ssh 127.0.0.1
Welcome to ...
Remote-PC $ exit
ログアウト
Connection to 127.0.0.1 closed.