1. Generate public and private keys

  • Open the command line and enter ssh-keygen -t rsa.
  • Then press three consecutive returns (the first to rename the file, and the second and third to set the password).

  • Finally, the generated public and private keys are found in drive C.


2. Write the public key to the server

Ps: The firewall of the server permits port 22.

  • Log in to the server using a password from the command line.

  • Paste the generated public key contents into the authorized_keys file.

  • Exit the server.
  • When reconnecting, you can log in without entering a password!


WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

  • An error is reported when configuring SSH connections after resetting the server: The remote host id has changed!

  • You need to delete the old connection information from your computer (based on the server IP).

  • Delete and reconnect.

The appendix

  • My personal blog is Messiwjy.top
  • If you have any errors or doubts, please contact [email protected]