1. Open PowerShell, execute ssh-keygen -t rsa -b 4096
(-b is to specify the key length), and then you will encounter the setting of the key generation path (including the key name), password, and password secondary verification. These three can be kept by default and directly enter
2. Switch the path, you can see an id_rsa.pub and id_rsa file under ~/.ssh , the former is the public key and needs to be uploaded to the ssh server
3. Open ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa.pub
Then select copy
4. Open the server side, switch the path to ~/.ssh , you can see that there is a file named authorized_keys , and append the public key copied above to the back of this file
(Optional) Prohibit password login
Open /etc/ssh/sshd_config , find PasswordAuthentication and change the following yes to no , to allow password login to change back to yes
5. Restart the ssh server
sudo service ssh restart
Or restart the server system