[ SSH Matters ]

Windows10 Command Prompt ->
ssh-keygen -t rsa -b 4096 -C "email address"
.ssh/id_rsa(Secret Key)
.ssh/ id_rsa.pub(Public Key)
Windows10 Command Prompt -> ssh -l pi 192.168.0.3

id_rsa.pub --> ~/.ssh authoraizedkeys
chmod 700 .ssh
chmod 600 .ssh/authorizedkeys
sudo chmod 644 /etc/ssh/sshd_config
sudo /etc/init.d/ssh restart

cat /proc/device-tree/model
cat /etc/os-release
cat /etc/debian_version

[ Setting sshd_config ]

/etc/ssh/sshd_config

PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server

After the above setting, restart ssh.

[ SSH Key Generation ]

ssh-keygen [オプション] -t 鍵タイプ [-N 新しいパスフレーズ] [-C コメント] [-f 鍵ファイル]
ssh-keygen -p [-P 古いパスフレーズ] [-N 新しいパスフレーズ] [-f 鍵ファイル]
ssh-keygen -i [-f 鍵ファイル]
ssh-keygen -l [-f 鍵ファイル]

Generate RSA key

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/karuma/.ssh/id_rsa): ← Enterキーを押します
Created directory '/home/karuma/.ssh'. ← ~/.ssh がない場合、ディレクトリを作成します
Enter passphrase (empty for no passphrase): ← パスフレーズを入力します
Enter same passphrase again: ← もう一度パスフレーズを入力します
Your identification has been saved in /home/karuma/.ssh/id_rsa.
Your public key has been saved in /home/karuma/.ssh/id_rsa.pub.

Change passphrase

$ ssh-keygen -p
Enter file in which the key is (/home/karuma/.ssh/id_rsa): ← Enterキーを押します
Enter old passphrase: ← 古いパスフレーズを入力します
Key has comment '/home/karuma/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase): ← 新しいパスフレーズを入力します
Enter same passphrase again: ← もう一度、新しいパスフレーズを入力します
Your identification has been saved with the new passphrase.

Replace key file

# ssh-keygen -i -f id_rsa.pub >> authorized_keys