How to Generate an SSH Key on Windows (and Copy It to Your Server)
Part of New VPS setup, our guide to this topic
To generate an SSH key on Windows, open PowerShell and run ssh-keygen -t ed25519. Accept the default path and set a passphrase. Windows saves the pair in C:\Users\you\.ssh. Windows has no ssh-copy-id, so copy the .pub file to the server’s ~/.ssh/authorized_keys with one PowerShell line instead.
On this page
- What ssh-keygen gives you: two files, one stays home
- Before you start
- How to generate an SSH key on Windows: 6 steps
- Key takeaways
- A VPS for this guide
- Stop typing the passphrase: ssh-agent on Windows
- Using PuTTY? Convert the key with PuTTYgen
- Common SSH key problems on Windows
- After your key works
- Questions
What ssh-keygen gives you: two files, one stays home
ssh-keygen writes two files. id_ed25519 is the private key. Microsoft’s OpenSSH key guide calls it the equivalent of a password: anyone who gets it can sign in as you. It never leaves your PC.
id_ed25519.pub is the public key, and you can share it freely. It goes into ~/.ssh/authorized_keys on every server you want to reach. That file holds one key per line, as the sshd manual describes, so a laptop and a desktop can each have their own line.
This guide covers the Windows side of step 4 in our new VPS setup checklist: making the key and getting it onto a Linux VPS. The theory (why the server can trust a key it never sees) and turning password login off are in our guide to SSH key login on a VPS.
Before you start
You need four things:
- Windows 10 (build 1809 or later) or Windows 11. The OpenSSH client is a Windows optional feature from build 1809 on.
- A Linux server with its IP address and a user name (often
rootorubuntuon a fresh Ubuntu 24.04 image). New to this? Start with what a VPS actually is. - One working way in. Either the server password, or the web console in your provider’s panel.
- Ten minutes.
First, check that the SSH client is there. Open PowerShell and run:
ssh -V
A version line means you’re ready. If PowerShell says ssh is not recognized, add OpenSSH Client under Settings > Optional features. Or run this in PowerShell opened as administrator, as the “Install OpenSSH Server & Client” section of Microsoft’s Get started with OpenSSH for Windows guide shows:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
How to generate an SSH key on Windows: 6 steps
In the commands, yourname and YOUR_SERVER_IP are placeholders. Swap in your own values before you press Enter.
Open PowerShell as your normal user
Press the Windows key, type PowerShell and open it. You don’t need “Run as administrator” for any of the key steps. Command Prompt works for everything except the PowerShell-only commands below, so stick with PowerShell.
Run ssh-keygen with the key type
your computerssh-keygen -t ed25519 -C "laptop-2026"
-t ed25519 picks the key type. Current OpenSSH already defaults to Ed25519; that changed in OpenSSH 9.5 (2023), and older builds made RSA keys. The OpenSSH in Windows can lag behind upstream, so name the type and remove the guess.
-C sets the comment at the end of the public key. Use something that tells you later which device the key belongs to, such as laptop-2026 or work-desktop.
Accept the default path and set a passphrase
ssh-keygen asks where to save the key:
outputEnter file in which to save the key (C:\Users\you/.ssh/id_ed25519):
Press Enter. The mixed slashes are normal on Windows. If a file with that name already exists, ssh-keygen asks before it overwrites. Answer n unless you mean to replace that key, because servers that trust the old one will stop letting you in.
Then it asks for a passphrase:
outputEnter passphrase (empty for no passphrase):
Enter same passphrase again:
Type it, press Enter, then type it again. Nothing shows on screen while you type. The passphrase encrypts the private key file, so a stolen copy can’t be used without it. Microsoft’s guide advises against leaving it empty. The ssh-agent section below means you’ll rarely have to type it.
Find the key files and read the public key
your computerdir $env:USERPROFILE\.ssh
You should see id_ed25519 and id_ed25519.pub. Print the public one:
your computerGet-Content $env:USERPROFILE\.ssh\id_ed25519.pub
Check: One long line that starts with ssh-ed25519, then a block of letters, then your comment. That whole line is what goes on the server.
To get the key’s fingerprint, a short hash you can compare later:
your computerssh-keygen -l -f $env:USERPROFILE\.ssh\id_ed25519.pub
Copy the public key to your server
On macOS and Linux, ssh-copy-id does this job. Windows doesn’t ship it: Microsoft’s OpenSSH overview lists ssh, sshd, ssh-keygen, ssh-agent, ssh-add, ssh-keyscan, sftp and scp, and nothing else. This PowerShell line does the same work:
your computertype $env:USERPROFILE\.ssh\id_ed25519.pub | ssh yourname@YOUR_SERVER_IP "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
type prints the key and pipes it into ssh. On the server, the quoted part creates ~/ if it’s missing and appends your key with >>, so keys already in the file stay. Then it locks the permissions down. sshd won’t use an authorized_keys file that other users can write to.
ssh asks for the server password one last time. If this is your first connection, it also asks whether you trust the server’s host key; our guide on how to SSH into a VPS explains that prompt.
If it fails: Permission denied (publickey) before any password prompt. The server already refuses passwords, so this line can’t get in. Use option C below.
There are two other ways to get the key on:
- A: the provider panel. Many providers let you paste a public key when you create the server, and the image then starts with it in place. Some only do this at creation: Hetzner’s docs say it can only store SSH keys on cloud servers when they’re created.
- C: paste by hand. Copy the key to the clipboard with the line below. Log in through the web console, open
~/in nano, and paste it as one line at the end..ssh/ authorized_keys
your computerGet-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard
Log in with the key
your computerssh yourname@YOUR_SERVER_IP
Check: A prompt for the key’s passphrase, worded like Enter passphrase for key 'C:\Users\you/. If ssh asks for the account password instead, the key wasn’t accepted; see the problems section.
Keep this session open the first time. Once key login works, you can turn password login off. Do that with the steps in our SSH key login guide, and test from a second window before you close the first.
Key takeaways
- To generate an SSH key on Windows, run
ssh-keygen -t ed25519 -C "device-name"in PowerShell and set a passphrase. - The private key stays in
C:\Users\you\.ssh. Only the.pubfile goes to servers. - Windows has no
ssh-copy-id; one PowerShell pipe appends the key toauthorized_keysinstead. - If password login is already off, paste the key through the provider panel or web console.
- Turn on the
ssh-agentservice once, and you’ll rarely type the passphrase.
A VPS for this guide
Everything above runs on any VPS with 1 GB of RAM. The cheapest 1 GB+ plan at each provider whose prices we read every day, IPv4 included:
| Plan · provider | vCPU · RAM · disk | You pay | Visit |
|---|---|---|---|
KVM VPS Special 1 GB RackNerd · Los Angeles +19 | 1 vCPU·1 GB·20 GB | $1.83/mo | |
VPS pico G11.5s netcup · Nuremberg | 1 vCPU·1 GB·30 GB | $2.00/mo | |
SSD VPS 1 CloudCone · USA | 2 vCPU·1 GB·30 GB | $2.33/mo | |
1 slice InterServer · New York +2 | 1 vCPU·2 GB·40 GB | $3.00/mo | |
NVMe 2 GB HostHatch · Amsterdam +15 | 1 vCPU·2 GB·10 GB | $4.00/mo |
Prices read Dec 4, 2026. gets that provider's deals on Telegram. Compare every 1 GB plan →
Stop typing the passphrase: ssh-agent on Windows
Windows ships an ssh-agent service that holds your unlocked key, but it is disabled by default. Turn it on once. Open PowerShell as administrator:
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
Then, in your normal PowerShell window, load the key:
ssh-add $env:USERPROFILE\.ssh\id_ed25519
Type the passphrase one more time. From now on, ssh gets the key from the agent. Microsoft’s guide says the agent stores the key within a Windows security context tied to your account. The same guide suggests backing up the private key somewhere safe; if you lose it, there’s no way to pull it back out of the agent.
The ssh-agent service ships disabled; the two administrator commands turn it on. Source: learn.microsoft.com, captured Nov 20, 2026.
Using PuTTY? Convert the key with PuTTYgen
PuTTY keeps private keys in its own .ppk format. You don’t need a second key pair. Open PuTTYgen, choose Conversions > Import key, pick id_ed25519, enter its passphrase, then click Save private key. The PuTTYgen manual documents that import and says the passphrase carries over.
If you create the key in PuTTYgen instead, copy the text from the box labelled “Public key for pasting into OpenSSH authorized_keys file”. That one line goes on the server like any other public key. Nothing changes on the server side.
Common SSH key problems on Windows
ssh-keygen is not recognized.The OpenSSH client isn’t installed. Add it under Settings > Optional features, or run the Add-WindowsCapability line from “Before you start” in an administrator PowerShell.
Permission denied (publickey) after copying the key.Check the user name first; root and ubuntu are different accounts with different authorized_keys files. Then check the key is in that user’s file as one unbroken line. Last, fix the permissions on the server with chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys.
WARNING: UNPROTECTED PRIVATE KEY FILE!ssh refuses a private key that other Windows users can read. The Win32-OpenSSH wiki says user keys must be owned by you with no one else having access. This often happens after you copy a key in from another folder or drive. Remove inherited access and give your account read access only:
icacls $env:USERPROFILE\.ssh\id_ed25519 /inheritance:r /grant:r "$($env:USERNAME):R"
Your account must own the key, and nobody else may read it. Source: github.com/PowerShell/Win32-OpenSSH/wiki, captured Nov 20, 2026.
Error connecting to agent when you run ssh-add.The ssh-agent service is stopped or disabled. Run the two administrator commands in the ssh-agent section.
You lost the private key.It can’t be rebuilt from the public key. Make a new pair, add the new .pub line to each server through the console, and delete the old line.
After your key works
- Turn off password login. Our SSH key login guide (linked above) covers how keys work, Ed25519 vs RSA, and switching passwords off without locking yourself out.
- Harden the rest of the box. The rest of that first-30-minutes checklist adds a firewall, automatic updates and an off-server backup.
- Choosing a server? Compare VPS prices by real monthly cost, with renewal prices and setup fees included. Hetzner is one example of a provider that only adds SSH keys at creation; its provider page has its plans and account terms.
Questions
Where does Windows save SSH keys?
In C:\Users\you\.ssh by default, which PowerShell writes as $env:USERPROFILE\.ssh. ssh-keygen shows the full path in its first prompt. Keep the default so ssh finds the key without extra options.
Should I use Ed25519 or RSA on Windows?
Ed25519 for any current Linux server. It’s the default in OpenSSH since 9.5, and the public key is one short line. Pick RSA only if a specific old system can’t take Ed25519.
Can I use the same SSH key on several servers?
Yes. Add the same .pub line to each server’s authorized_keys. A separate key per device is the better habit: if a laptop is lost, you delete that one line everywhere and your other devices keep working.
Do I need PuTTY to generate an SSH key on Windows?
No. Windows 10 and 11 include ssh-keygen in the OpenSSH client. PuTTYgen is only useful if you already log in with PuTTY, and it can import the key you made here.
Is it safe to generate an SSH key without a passphrase?
It works, but anyone who copies the private key file can then log in as you. A passphrase plus the ssh-agent service costs you one prompt and closes that gap.
How we checked: Every command comes from Microsoft’s OpenSSH documentation, the OpenBSD manual pages for ssh-keygen and sshd, or the PuTTY manual, read on November 14, 2026. We did not run them on every Windows build or provider image. How we check.