Creating SSH keys
Create a secure SSH key pair in 5 minutes, so you can log into your own server without a password (and without the risk).
- Beginner
- 8 min
- free
- Draft · not tested yet
- Completed
Before you rent a server, you first create your key. You’ll use it to log into your VPS: safer than a password and faster, because there’s nothing to type.
After this lesson you have: an SSH key pair on your computer, and you know which part you may share and which part never.
How it works (in one picture)
Section titled “How it works (in one picture)”An SSH key consists of two files that belong together:
flowchart LR
A["🔑 Private key<br/>id_ed25519<br/>(stays on your computer)"] -- proves who you are --> S[("🖥️ Server")]
B["🔓 Public key<br/>id_ed25519.pub<br/>(fine to put anywhere)"] -- lives on --> S
Think of the public key as a lock you put on your server’s door, and the private key as the only key that fits that lock.
Step by step
Section titled “Step by step”-
Open a terminal.
Open Terminal (Cmd + Space → type “Terminal”).Open PowerShell (Start → type “PowerShell”). OpenSSH ships with Windows 10 and 11.Open your terminal (often Ctrl + Alt + T). -
Check whether you already have a key.
Terminal window ls ~/.sshTerminal window ls $env:USERPROFILE\.sshTerminal window ls ~/.sshSee
id_ed25519andid_ed25519.pub? Then you already have one — skip to step 5. No passphrase on it yet? Add one withssh-keygen -p(enter the path to yourid_ed25519when asked). Getting an error or an empty folder? Just carry on. -
Create the key pair. Replace the email address with yours (it’s just a label).
Terminal window ssh-keygen -t ed25519 -C "you@example.com"When asked where to save the file, just press Enter (the default location is fine).
-
Choose a passphrase. Don’t leave it empty: it protects your key if someone gets hold of your laptop (or the file). Nothing appears while you type — that’s expected.
What you should see now
Generating public/private ed25519 key pair.Enter file in which to save the key (/Users/you/.ssh/id_ed25519):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /Users/you/.ssh/id_ed25519Your public key has been saved in /Users/you/.ssh/id_ed25519.pubThe key fingerprint is:SHA256:… you@example.com -
View your public key. You’ll copy this to your VPS provider later.
Terminal window cat ~/.ssh/id_ed25519.pubTerminal window Get-Content $env:USERPROFILE\.ssh\id_ed25519.pubTerminal window cat ~/.ssh/id_ed25519.pubWhat you should see now
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA… you@example.comOne line, starting with
ssh-ed25519. That’s what you share. -
Let your computer remember the passphrase (optional, saves typing).
Terminal window ssh-add --apple-use-keychain ~/.ssh/id_ed25519In PowerShell as administrator:
Terminal window Get-Service ssh-agent | Set-Service -StartupType AutomaticStart-Service ssh-agentssh-add $env:USERPROFILE\.ssh\id_ed25519Terminal window eval "$(ssh-agent -s)"ssh-add ~/.ssh/id_ed25519
Checklist
0/4
Your progress is only stored in this browser.
Test yourself
1Which file may you give to your VPS provider?
Only the public key (.pub). The private key always stays on your own computer.
2Why set a passphrase?
3Nothing appears while you type your passphrase. Now what?
Next lesson: renting a VPS from an EU provider and adding this key straight away.