How-to

Log In to Your Machine with an SSH Key

Keys replace the root password with a file only you hold. Add the public half in the panel before ordering and your first login needs no password at all.

Why use a key instead of the root password?

A key cannot be guessed, phished from a login form or reused from another site. It is a pair of files: a private key that stays on your computer, protected by a passphrase, and a public key you copy to servers. The server checks that you hold the private half without it ever leaving your laptop. Once key login works you can switch off passwords entirely, which ends brute-force attempts against your machine. Background on the idea is in the SSH keys entry.

How do I create a key?

Use ed25519. It is short, fast and supported by every current OpenSSH. On Linux, macOS or Windows PowerShell:

ssh-keygen -t ed25519 -C "lena@studio-laptop" -f ~/.ssh/cd_ed25519

Choose a passphrase when asked. The passphrase scrambles the key file at rest, which makes a lost notebook or a copied backup worthless to whoever finds it. The command creates two files: cd_ed25519, the private key, and cd_ed25519.pub, the public key. Only the .pub file is ever shared.

If you must support a very old system that lacks ed25519, create an RSA key with -t rsa -b 4096 instead. Everything on our images handles ed25519, so that fallback is only for legacy hardware elsewhere.

How do I put the key on a new machine?

The easiest way is before installation. In the panel, open SSH keys, paste the single line from the .pub file and give it a name. When you order or reinstall, tick that key; it is added to root's authorized_keys during the install. Print the line to copy:

cat ~/.ssh/cd_ed25519.pub
# ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK9... lena@studio-laptop

Copy the whole line, including the ssh-ed25519 prefix, as one line with no breaks.

How do I add a key to a machine that is already running?

Use ssh-copy-id, which logs in with the password once and appends the key with correct permissions:

ssh-copy-id -i ~/.ssh/cd_ed25519.pub root@203.0.113.25

Windows does not ship ssh-copy-id. In PowerShell, pipe the key over SSH instead:

type $env:USERPROFILE\.ssh\cd_ed25519.pub | ssh root@203.0.113.25 "umask 077; mkdir -p .ssh; cat >> .ssh/authorized_keys"

How do I connect with the key?

ssh -i ~/.ssh/cd_ed25519 root@203.0.113.25

If you only see a passphrase prompt and no password prompt, it worked. To avoid typing -i, add a host block to ~/.ssh/config with IdentityFile, as shown in The SSH config file, and load the key into ssh-agent so the passphrase is asked once per session.

Which key types can I use?

TypeKey lengthNotes
ed25519256 bit, short lineBest default for people and automation
ed25519-skStored on a FIDO2 tokenNeeds the hardware key and a touch to log in
ecdsa256 to 521 bitWorks everywhere; ed25519 is simpler
rsa3072 or 4096 bitFor legacy systems only
dsa1024 bitRemoved in OpenSSH 10.0; do not use

How do I keep the private key safe?

  • Always set a passphrase; change it later with ssh-keygen -p.
  • Keep a backup in a password manager or encrypted vault. Losing the only copy, with passwords disabled on the server, means a reinstall.
  • Use separate keys for separate jobs: one for you, one per automation, so revoking one does not break the others.
  • Never copy a private key onto a server. Use ProxyJump to hop between machines instead.

What next once key login works?

Create a personal sudo user with the same key, then turn off password authentication. The full sequence is in Set up passwordless SSH. If anything refuses your key, Fix "Permission denied (publickey)" covers the usual causes.

Keep Reading

SSH keys

How SSH key pairs replace passwords, how to make an ed25519 key and how to have it placed on your machine at install time.

Open

Set up passwordless SSH

Go from a root password to key-only access in one careful pass: user, key, agent, then switch off every password method on the server.

Open

Fix "Permission denied (publickey)"

Trace a publickey refusal to its real cause: wrong key, wrong user, loose file modes, SELinux labels or an old RSA signature.

Open

The SSH config file

Turn long ssh command lines into short aliases with ~/.ssh/config: hosts, ports, keys, jump hosts, keepalives and connection sharing.

Open

FAQ

Quick Answers

ed25519. It is short, fast and supported by every image we install.

Yes. Save it under SSH keys in the panel and select it when ordering or reinstalling; it is placed in root's authorized_keys.

For personal keys, yes. It protects the key if your computer or a backup is stolen.

Windows lacks ssh-copy-id, so pipe the .pub file through ssh into .ssh/authorized_keys, as shown above.

Log in with another key or the password if still enabled and replace it. If no access remains, reinstall from the panel with a new key selected.