Skip to content
XXD VPS Guide
中文
  1. Wiki
  2. Security
  3. SSH, public and private keys

SSH, public and private keys

SSH is how you log in to a server remotely and run commands on it. Logging in with keys is far safer than with a password.

Think of it like this

Keys are a lock and its only key: the public key is the lock, fitted to the server's door; the private key is the key, kept only on your computer. The door opens only when they match — nobody can guess it.

In this setup

Step 3 creates a key pair on your computer, puts the public key on the server and adds a name to ~/.ssh/config. After that ssh your-name logs you straight in. Once set up, the server turns off password login and only accepts your computer's private key.

Common misconceptions

  • "I can send my private key to someone to take a look": the private key is the server's key. Never give it to anyone.
  • "After changing computers I'm locked out": use your provider's rescue console to log in and add the new computer's public key.

Related: Ports, Firewall

This setup is for you and your family only. Follow local laws and each site's and AI tool's terms of use. Open source (MIT) — code and feedback on GitHub.