You can generate SSHSSH A secure way to type commands on a server from your own computer, as if you were sitting at it. More about SSH → keys on Windows 10 and Windows 11 with the ssh-keygen command that is already built in, without installing anything. This guide is for Windows users who need a key to log in to a Linux server, a VPSVPS A private slice of a powerful server, with its own guaranteed share of memory and processing and full control, at a fraction of the price of a whole machine. More about VPS → or a hosting account, and want to know exactly where the files end up and how to use them.
Open PowerShell and run **ssh-keygen -t ed25519 -C "my-laptop", press Enter to accept the default location, and choose a passphrase. Your keys are saved in C:\Users\yourname\.ssh\** as id_ed25519 (private, keep it secret) and id_ed25519.pub (public, safe to share). Copy only the .pub file’s contents to the server or service you want to log in to.
If you are new to the idea of a key pair, read what SSH keys are and how they work first. The short version: the private key stays on your PC and proves who you are, and the public key goes on every server that should let you in.
Check that the OpenSSH client is installed
Windows ships the OpenSSH client (the ssh, scp, ssh-keygen and ssh-add programs) as an optional feature that is switched on by default on current Windows 10 and Windows 11 installs. Check it by opening PowerShell (right-click the Start button, then choose Terminal or Windows PowerShell) and running:
ssh -V
Success looks like a version line such as OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2. The exact numbers vary and do not matter here.
If you see “ssh is not recognized as the name of a cmdlet”, add the client:
- Windows 11: Settings, System, Optional features, View features, then search for OpenSSH Client.
- Windows 10: Settings, Apps, Optional features, Add a feature, then OpenSSH Client.
Or, in a PowerShell window opened with Run as administrator:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Close and reopen PowerShell afterwards so it picks up the new commands.
Generate the key pair with ssh-keygen
1. Run ssh-keygen
In a normal (not administrator) PowerShell window, run:
ssh-keygen -t ed25519 -C "exampleco-laptop"
-t ed25519picks the Ed25519 key type, the current recommendation: short, fast and strong.-Cadds a comment to the end of the public key. It is only a label, so use something that tells you later which computer the key belongs to.
If you must log in to a very old system that does not accept Ed25519, use ssh-keygen -t rsa -b 4096 instead.
2. Accept the default location
You will be asked:
Enter file in which to save the key (C:\Users\exampleco/.ssh/id_ed25519):
Press Enter. The mix of \ and / in that path is normal on Windows and harmless. Keeping the default name matters, because ssh looks for id_ed25519 automatically. If a key with that name already exists, ssh-keygen asks whether to overwrite it: answer n unless you are sure the old key is not used anywhere, or you will lock yourself out of every server that trusted it.
3. Set a passphrase
Next you are asked for a passphrase. Nothing appears on screen as you type, which is expected. A passphrase encrypts the private key file, so a stolen laptop or a leaked backup does not hand over your server access. You can leave it empty by pressing Enter twice, but a passphrase plus ssh-agent (below) gives you the safety without typing it every time.
When it finishes, you see a key fingerprint starting SHA256: and a small block of characters called the randomart image. That means the keys were created.
4. Find your files
dir $env:USERPROFILE\.ssh
You should see:
| File | What it is | Share it? |
|---|---|---|
id_ed25519 | Private key | Never |
id_ed25519.pub | Public key | Yes, this is the one servers need |
known_hosts | Servers you have connected to before | Not needed |
The .ssh folder is inside your user folder, for example C:\Users\exampleco\.ssh. File Explorer may hide the extension, so the public key can show as id_ed25519 with the type “PUB File”. Go by the type, not the name.
Load the key into ssh-agent
ssh-agent is a small background service that holds your unlocked private key in memory, so you type the passphrase once per session instead of on every connection. On Windows the service is installed but disabled by default. In PowerShell opened with Run as administrator, run:
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
Then, back in your normal PowerShell window, add your key:
ssh-add $env:USERPROFILE\.ssh\id_ed25519
Enter the passphrase once. Identity added means it worked. Check with ssh-add -l, which lists the fingerprint of each loaded key. The Windows agent remembers added keys across restarts, so this is a one-time step.
Put the public key on a server
Only the public key ever leaves your computer. There are three common ways to install it.
Copy it to a Linux server from PowerShell
Windows does not include ssh-copy-id, so this one line does the same job. Replace the user name and address with your own:
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh exampleco@203.0.113.10 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
You log in with your password one last time. The command appends your key to ~/.ssh/authorized_keys, the file the server checks for allowed keys, and sets the strict permissions SSH insists on.
Paste it into a control panel or website
cPanelcPanel The most popular hosting control panel: a website where you manage your email, files, databases and domains with point-and-click tools instead of commands. More about cPanel →, Git hosting sites and cloud dashboards ask you to paste the public key into a box. Copy it to the clipboard with:
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard
The key is a single line starting ssh-ed25519. If what you paste starts with -----BEGIN OPENSSH PRIVATE KEY-----, stop: that is the private key.
Test the login
ssh exampleco@203.0.113.10
If you get in without being asked for the server password, the key works. If this is your first time connecting to that server, the connection guide explains the host key prompt you will see. Once key login works, you can switch password login off by following how to set up SSH keys.
If you use PuTTY or Git Bash
PuTTY uses its own key format, .ppk. You have two options:
- Generate the key in PuTTYgen (installed with PuTTY): choose EdDSA with Ed25519, click Generate, move the mouse to add randomness, set a passphrase, then Save private key. Copy the text from the box labelled “Public key for pasting into OpenSSH authorized_keys file” to the server.
- Keep the key you made with ssh-keygen and convert it: in PuTTYgen choose Conversions, Import key, select
id_ed25519, then Save private key to create a.ppkcopy.
Git Bash has its own ssh-keygen and uses the same C:\Users\yourname\.ssh folder, so a key made in PowerShell works there too. Use one tool’s agent at a time to avoid confusion.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
ssh-keygen is not recognized | OpenSSH Client feature is missing | Add it under Optional features, then reopen PowerShell |
unable to start ssh-agent service, error :1058 | The ssh-agent service is disabled | Run the two Set-Service and Start-Service commands as administrator |
Error connecting to agent: No such file or directory | The agent service is not running | Run Start-Service ssh-agent as administrator |
| Still asked for the server password | Public key not in authorized_keys, or wrong user name | Repeat the copy step for the same user you log in as |
WARNING: UNPROTECTED PRIVATE KEY FILE! | The private key was copied in from elsewhere and other accounts can read it | Recreate it with ssh-keygen in your own profile, or remove other users’ access in the file’s Properties, Security tab |
Permission denied (publickey) | Server only accepts keys and none of yours match | Check ssh-add -l and that the matching .pub is on the server |
Back up your private key somewhere safe and private, such as an encrypted password manager. If you lose it, you need another way into the server to add a new key.
Official documentation
Related
- What are SSH keys? explains how the public and private halves prove who you are.
- How to set up SSH keys covers turning off password and root login once your key works.
- How to connect to a server with SSH walks through your first login from Windows.
- Git Bash for Windows gives you a Linux-style terminal with the same SSH tools.
Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.



