# How to set up SSH keys on a VPS?

> How to set up SSH keys on a VPS in 6 steps: ssh-keygen -t ed25519, paste the .pub line, test the login, then turn password login off with sshd -t.

- URL: https://ironkvm.com/guides/how-to-set-up-ssh-keys-on-a-vps/
- Last updated: 2026-11-16
- Publisher: IronKVM (https://ironkvm.com)

Create an Ed25519 key pair, give the server the public half, check that it works, then close the door to passwords for good.

**Quick answer — How to set up SSH keys on a VPS?**

To set up SSH keys on a VPS, run ssh-keygen -t ed25519 on your computer, copy the one-line .pub file to the server, log in with the key, then set PasswordAuthentication no. At **IronKVM** you can paste the public key at checkout, so the server is delivered with password login already off, within 1 hour.

**In brief**

- Ubuntu documentation recommends Ed25519 keys; RSA with 4096 bits is the fallback.
- Only the line from the .pub file goes to the server; the private key never leaves your computer.
- Root over SSH. Paste a public key at checkout and password login stays off; leave it empty and the team sets a temporary root password, shown in the dashboard, to change at first login.
- Test the key in a second terminal before you turn password login off.
- Check the config with sshd -t before restarting the service.

## Which file does what in SSH key login?

*Files used for SSH key login on a Debian or Ubuntu VPS, from Ubuntu Server documentation and the OpenSSH manual*

| File | Where | Role |
| --- | --- | --- |
| ~/.ssh/id_ed25519 | Your computer | Private key: keep it secret |
| ~/.ssh/id_ed25519.pub | Your computer | Public key: the line you paste |
| ~/.ssh/authorized_keys | The VPS, in the user’s home | List of public keys allowed to log in |
| /etc/ssh/sshd_config.d/*.conf | The VPS | Drop-in settings read before the main file |
| /etc/ssh/sshd_config | The VPS | Main SSH server settings |

## What are the steps to set up SSH keys on a VPS?

1. **Create the key pair** — On Linux, macOS or Windows PowerShell, run ssh-keygen -t ed25519 and press Enter to accept the defaults. Add a passphrase if you want one.
2. **Show the public key** — Print the .pub file and copy the whole line. It starts with ssh-ed25519.
3. **Give the key to the server** — Paste it at checkout, or on a running server use ssh-copy-id user@VPS_IP.
4. **Log in with the key** — Run ssh root@VPS_IP or ssh user@VPS_IP. No password prompt should appear.
5. **Turn password login off** — Create a drop-in file with PasswordAuthentication no and KbdInteractiveAuthentication no.
6. **Test and restart** — Run sshd -t, restart the ssh service, and open a new session before closing the old one.

*On your computer*

```bash
ssh-keygen -t ed25519
cat ~/.ssh/id_ed25519.pub
# on a server that already runs, copy the key over
ssh-copy-id root@VPS_IP
```

## How do you add the key at the IronKVM checkout?

**Paste the .pub line in the “SSH public key” field before paying.** The checkout accepts one line that starts with ssh-ed25519, ssh-rsa or ecdsa-sha2. With a key, password login stays off and only your key opens root. The checkout also shows the ssh-keygen command for each system.

No key? Leave the field empty. A team member then sets a temporary root password, shown in the dashboard. Log in, run `passwd`, then add your key as below. If you reinstall later, the reinstall dialog has a “New SSH public key” field; leave it empty to keep the key from the order. The [first SSH login guide](https://ironkvm.com/help/first-ssh-login/ "How do I log in to an IronKVM VPS over SSH the first time?") covers both cases.

*On the VPS: add a key by hand (temporary password case)*

```bash
mkdir -p ~/.ssh && chmod 700 ~/.ssh
echo 'ssh-ed25519 AAAA... you@laptop' >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
```

## How do you turn password login off safely?

**Put the settings in a drop-in file, test the syntax, and keep one session open while you test.** Ubuntu documentation explains that the main sshd_config includes /etc/ssh/sshd_config.d/*.conf at the very top. OpenSSH keeps the first value it reads for most settings, so a file named 00-… wins over later ones.

The OpenSSH manual says PasswordAuthentication and KbdInteractiveAuthentication both default to yes, and PermitRootLogin defaults to prohibit-password. That default already blocks root passwords but allows root keys. If you work as a normal user with sudo, set PermitRootLogin no as well. Then run `sshd -t`: it prints nothing when the file is valid.

*/etc/ssh/sshd_config.d/00-keys-only.conf*

```bash
# write the drop-in file
sudo tee /etc/ssh/sshd_config.d/00-keys-only.conf <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
EOF
sudo sshd -t
sudo systemctl restart ssh.service
```

## What does a VPS with key-only root access cost?

**Every IronKVM plan includes root over SSH; the price depends on size, not on access.** Billet costs $4.46 a month on 12 months and Ingot $8.25. According to IronKVM's survey of 16 November 2026, plans comparable to Ingot cost a median of $25.49 a month across 20 hosts.

After keys, the next steps are a firewall and ban rules. The [offshore VPS security guide](https://ironkvm.com/guides/how-to-secure-an-offshore-vps/ "How to secure an offshore VPS?") puts them in order, and [how to install fail2ban](https://ironkvm.com/guides/how-to-install-fail2ban/ "How to install fail2ban?") blocks addresses that keep guessing.

## SSH keys on a VPS: questions

### Which SSH key type is best in 2026?

Ed25519. Ubuntu documentation recommends it for its short keys and low computing cost; RSA 4096 is the fallback for old systems.

### I lost my private key. What now?

Nobody can recover it. Request a reinstall from the dashboard with a new public key; a reinstall wipes the disk.

### Can I use one key for several servers?

Yes. The same public key can sit in authorized_keys on any number of servers.

### Should I add a passphrase?

Yes if the computer could be lost or shared. ssh-agent keeps typing to once per session.

### Does IronKVM ever ask for my private key?

No. The dashboard says it plainly: keep the private key safe, it is never asked for.

**Verdict**

- **Create an Ed25519 key and paste it at checkout**: the IronKVM server then arrives with password login off.
- **On a server that already runs**, add the key, test it, then set PasswordAuthentication no in a drop-in file and check it with sshd -t.

## Sources

1. [OpenSSH server](https://ubuntu.com/server/docs/how-to/security/openssh-server/) — Canonical (read 2026-11-16)
2. [sshd_config(5)](https://man.openbsd.org/sshd_config) — OpenBSD (read 2026-11-16)
3. [IronKVM client area: checkout and server screens (vpshost module)](https://ironkvm.com/app/checkout/) — IronKVM (read 2026-11-16)
4. [IronKVM offshore VPS survey (CSV)](https://ironkvm.com/data/ironkvm-offshore-vps-survey-2026-11-16.csv) — IronKVM (read 2026-11-16)

**Order a VPS with your SSH key** Paste your key at checkout. Ingot, 2 vCPU, 4 GB RAM, 80 GB NVMe, 4 TB traffic, $8.25 a month on 12 months. [Order Ingot](https://ironkvm.com/app/checkout/?plan=ingot&term=12m&from=guide-ssh-keys&lang=en) · [Compare the plans](https://ironkvm.com/pricing/ "IronKVM prices 2026: how much does an offshore KVM VPS cost?")

---

IronKVM: IronKVM is an offshore KVM VPS provider with servers in the Netherlands, Romania and Moldova that takes no action on DMCA takedown notices, for content that is legal in the server's country. It is paid in crypto with no ID upload and run by DomaineGoat LLC, a company registered in Panama. On the 12-month term each plan costs at least 25% less than a named comparable plan read on 16 November 2026.
