Black Friday: Save 10% for life on all of our VPS plans, now through Cyber Monday

10% off on selected plans for as long as you keep the service · new orders · up to 10 uses per customer · ends Dec 1, 2026, 12:00 AM EST.

See plans
Guideschevron_rightServers

Servers · 8 min read · Updated

How to Use SSH Keys on Windows, Mac and Linux

To use SSH keys, run ssh-keygen -t ed25519 on your own computer (it works the same in Windows PowerShell, macOS Terminal and Linux), give the key a passphrase, and copy the .pub file's contents into ~/.ssh/authorized_keys on the server, with ssh-copy-id on macOS and Linux or one PowerShell line on Windows. Load the key into the SSH agent so you type the passphrase once, and use ~/.ssh/config to give each server a short name.

1. Make a Key

Windows 10 and 11 include the OpenSSH client, so the same command works in PowerShell, macOS Terminal and a Linux shell:

ssh-keygen -t ed25519 -C "my laptop"

Press Enter to accept the file name, then type a passphrase. You get two files in the .ssh folder of your home directory (C:\Users\you\.ssh on Windows):

  • id_ed25519, the private key. It stays on this computer.
  • id_ed25519.pub, the public key. This one goes on servers.

The comment after -C ends up at the end of the public key, so you can tell later which computer a key on a server belongs to.

2. Put It on the Server

On a new server, paste the public key into the SSH key field when you order a Linux server, and it is installed for root; see managing SSH keys.

On a running server, from macOS or Linux:

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

Windows has no ssh-copy-id; 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"

Both ask for the account's password one last time. Then ssh [email protected] should ask for the key's passphrase instead. Once it does, you can turn off password logins altogether.

3. Type the Passphrase Once

The SSH agent holds the unlocked key in memory, so you are not asked on every connection.

Windows: the agent is a service that is off by default. In PowerShell as administrator:

Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent

Then, as yourself:

ssh-add $env:USERPROFILE\.ssh\id_ed25519

macOS: store the passphrase in the Keychain once:

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Then add these lines to ~/.ssh/config so SSH reads it from there:

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

Linux: most desktops start an agent for you, and ssh-add loads the key into it. Add AddKeysToAgent yes to ~/.ssh/config to load it the first time you use it.

4. Several Servers and Several Keys

~/.ssh/config gives each server a short name and says which key to use. On Windows the file is C:\Users\you\.ssh\config, with no extension:

Host web
  HostName 203.0.113.10
  User alice
  IdentityFile ~/.ssh/id_ed25519

Host backup
  HostName 198.51.100.20
  User root
  Port 2222
  IdentityFile ~/.ssh/backup_ed25519
  IdentitiesOnly yes

Now ssh web is the whole command, and scp, rsync and editors such as VS Code's Remote SSH read the same names. IdentitiesOnly yes stops SSH offering every key the agent holds, which otherwise can hit the server's limit on attempts and end in “Too many authentication failures”.

5. Using PuTTY or WinSCP

PuTTY and WinSCP use their own .ppk key format. Open PuTTYgen, choose Conversions → Import key, select id_ed25519, enter the passphrase, and Save private key as a .ppk file. In PuTTY, set it under Connection → SSH → Auth → Credentials. The public key on the server stays the same.

If the Key Is Refused

  • Permissions: on the server, ~/.ssh must be 700 and authorized_keys 600, owned by that user; SSH ignores keys in files others can write.
  • Wrong user: a key added for root does not let you in as alice; each account has its own authorized_keys.
  • See what happens: ssh -v web shows which keys are offered and which are refused. Fixing SSH errors covers the messages one by one.
  • Locked out: on a VPS, the browser console in the dashboard still accepts the password, so you can fix the file from there.

When a laptop is lost or someone leaves, delete their key's line from authorized_keys on every server; the comment at the end of each line tells you whose it is.

Common Questions

  • Ed25519 or RSA?

    Ed25519 for anything current: the keys are short, fast and secure. Make an RSA key (ssh-keygen -t rsa -b 4096) only for an old system that does not accept Ed25519.

  • Should my key have a passphrase?

    Yes. Without one, anyone who copies the private key file can use it. With the SSH agent or the macOS Keychain you type the passphrase once per session, not on every connection.

  • Which file do I give to the server?

    The one ending in .pub. The other file is the private key and never leaves your computer: not in email, chat or a support ticket.

  • Can I use the same key for every server?

    You can, and many people use one key per computer. Separate keys are useful when access must be removed on its own, such as a key used by a deployment tool, so the ~/.ssh/config section below shows how to keep several.

Plans and prices

VPS Plans

Linux and Windows servers with full root access. Paste your public key at checkout.

See all plans
  • Bronze

    3 vCPU · 6 GB RAM · 75 GB NVMe

    2 TB transfer

    $37.50/mo

    Configure inAshburnDallas
  • Silver

    4 vCPU · 8 GB RAM · 100 GB NVMe

    4 TB transfer

    $46.50/mo

    Configure inAshburnDallas
  • Gold

    6 vCPU · 12 GB RAM · 150 GB NVMe

    6 TB transfer

    $60.00/mo

    Configure inAshburnDallas
  • Diamond

    8 vCPU · 16 GB RAM · 200 GB NVMe

    8 TB transfer

    $73.50/mo

    Configure inAshburnDallas

Network port: 10 Gbps in Ashburn, VA, 50 Gbps in Dallas, TX. Pick the location when you configure.

Keep Reading

All guides