Skip to main content
To generate an SSH key, run ssh-keygen -t ed25519 -C "alex@laptop" on your own computer and set a passphrase. Then add the public key to the server with ssh-copy-id -i ~/.ssh/id_ed25519.pub alex@203.0.113.10 (macOS and Linux), or append the contents of id_ed25519.pub to ~/.ssh/authorized_keys on the server. Your next ssh alex@203.0.113.10 logs in with the key instead of the server password.

Before you start

  • You need to be able to log in to the server once, with a password, to install the key. Or add the key in the VPS Control Panel before you rebuild the VPS.
  • An SSH key comes in two files. The private key (id_ed25519) stays on your computer and is never shared. The public key (id_ed25519.pub) goes on every server you want to log in to.

Which key type should I use?

Use Ed25519. It is short, fast and supported by every current OpenSSH server. Use RSA with 4096 bits only for old systems that don’t accept Ed25519.

How to generate an SSH key

The command is the same in PowerShell on Windows and in Terminal on macOS and Linux.
1

Run ssh-keygen

The -C text is a label that helps you recognise the key later.
2

Accept the file location

Press Enter to save to the default location: ~/.ssh/id_ed25519 on macOS and Linux, C:\Users\<you>\.ssh\id_ed25519 on Windows.
3

Set a passphrase

Type a passphrase twice. It encrypts the private key, so a stolen laptop doesn’t mean a stolen server.
4

Check the result

How to add the public key to your server

ssh-copy-id logs in with your password once and appends the key with the right permissions:
For a non-standard SSH port, add -p 2222.
The key goes into the home folder of the user you log in as: /root/.ssh/authorized_keys for root, /home/alex/.ssh/authorized_keys for alex. If you created the folder as root for another user, give it back to that user with sudo chown -R alex:alex /home/alex/.ssh.

How to check it worked

Log in again from your computer:
You are asked for the key passphrase (Enter passphrase for key ...), not the server password. To prove the key alone works, force SSH to skip passwords:
If that logs you in, you can safely disable password logins.
Keep a backup of your private key. If you lose it after turning off password logins, you can only get back in through the VNC console or rescue mode on a VPS, or by opening a ticket for a dedicated server.

Frequently asked questions

Can I use the same key for several servers?

Yes. Add the same public key to each server. If one computer is lost, remove that key line from authorized_keys on every server.

How do I avoid typing the passphrase every time?

Use the SSH agent. On macOS and Linux, run ssh-add ~/.ssh/id_ed25519 once per login session. You can also add AddKeysToAgent yes to your SSH config file.

Why does the server still ask for a password?

The key isn’t in the right authorized_keys file, the line is broken, or the permissions are too open. SSH refuses keys when ~/.ssh or authorized_keys is writable by other users. See permission denied (publickey).

How do I use this key with PuTTY or WinSCP?

PuTTY needs a .ppk copy. Convert it in PuTTYgen with Conversions > Import key. See How to use PuTTY.

VPS and dedicated server guides

Every guide in this section.

Disable password login

Allow SSH keys only.

SSH config shortcuts

Pick the right key per server automatically.

Use PuTTY

Keys in PuTTY’s .ppk format.

Manage SSH keys in the VPS panel

Add keys before a rebuild.

Checked against the official OpenSSH ssh-keygen manual and Microsoft Learn: OpenSSH key management on 4 November 2026; ssh-keygen, ssh-copy-id and key login tested with OpenSSH 9.6 on Ubuntu 24.04 LTS. The PowerShell one-liner was not tested on Windows.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026