Skip to content
VeloxMedia
VPS guide

Set Up SSH Key Authentication for Your VPS

SSH keys replace a password that can be guessed with a cryptographic key pair that cannot. Setting them up takes five minutes and makes every later login faster as well as safer.

Beginner · About 3 min read · Updated 27 October 2026

How key authentication works

You generate two files. The private key stays on your computer and never leaves it. The public key is copied to every server you want to reach, into ~/.ssh/authorized_keys. When you connect, the server sends a challenge that only the matching private key can answer. Nothing secret crosses the network, so there is nothing to intercept or brute-force.

1. Generate a key

Ed25519 keys are short, fast and secure, and every current SSH server supports them. The same command works in macOS Terminal, Linux and Windows PowerShell:

ssh-keygen -t ed25519 -C "you@laptop"

Accept the default location (~/.ssh/id_ed25519) and set a passphrase. The passphrase encrypts the private key on disk, so a stolen laptop does not mean stolen servers. An SSH agent remembers it for your session so you are not prompted every time.

2. Copy the public key to the server

On macOS and Linux:

ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]

Windows does not ship ssh-copy-id, so pipe the key over in PowerShell:

type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh [email protected] "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

You can also paste a public key into the customer portal when you deploy a server, so it is installed for root on first boot.

3. Test the key

ssh -i ~/.ssh/id_ed25519 [email protected]

If you were asked for the key passphrase rather than the account password, it worked.

4. Add a shortcut in ~/.ssh/config

Typing addresses gets old quickly. Create or edit ~/.ssh/config on your computer:

Host web1
    HostName 203.0.113.10
    User deploy
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes
    ServerAliveInterval 30

Now ssh web1 connects, and scp file.tar.gz web1: and rsync -av site/ web1:/var/www/site/ use the same settings.

5. Use an agent

On macOS add UseKeychain yes and AddKeysToAgent yes under Host *. On Windows, enable the OpenSSH Authentication Agent service once:

Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519

On Linux desktops the agent usually runs already; ssh-add loads the key.

6. Disable password logins

Only do this after step 3 succeeds. On the server:

sudo tee /etc/ssh/sshd_config.d/10-keys-only.conf >/dev/null <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
EOF
sudo sshd -t && (sudo systemctl reload ssh || sudo systemctl reload sshd)

Confirm from another terminal that ssh -o PubkeyAuthentication=no [email protected] is now refused.

Managing keys over time

  • Use one key per device, so losing a laptop means removing one line from authorized_keys, not rotating everything.
  • Remove keys for people who leave a project the same day.
  • Back up your private key securely, or make sure you can still reach servers through the VeloxMedia browser console if it is lost.
  • For automation such as CI deploys, create a separate key without a passphrase, restricted to a dedicated user.

Common questions

Which SSH key type should I use?

Use Ed25519. It is fast, produces short keys and is supported by all current SSH servers. Use RSA with at least 3072 bits only if you must connect to very old systems.

Should my SSH key have a passphrase?

Yes for personal keys. The passphrase encrypts the private key on disk, and an SSH agent remembers it during your session. Keys used by automated deploys can go without one if they are restricted to a dedicated user.

How do I copy an SSH key from Windows?

Windows has no ssh-copy-id, so pipe the public key over SSH with PowerShell and append it to ~/.ssh/authorized_keys on the server, or paste the public key into the portal when you deploy the server.

What if I lose my private key?

Log in through the browser-based console in the VeloxMedia control panel, add a new public key to authorized_keys, and remove the old one. That is why it helps to keep a second key or console access available.

Deploy your first server in under a minute

Pick a region, choose a size and connect over SSH. No setup fees, cancel anytime.