Part 2: Connect from your computer
8. SSH from Windows#
What you'll do: the same as Chapter 7, from a Windows 10 or 11 PC. SSH is already built into Windows. Time: 20 minutes. Read the "What is a key?" picture in Chapter 7 if you skipped it.
Open PowerShell: press the Windows key, type PowerShell, press Enter. The prompt looks like PS C:\Users\alex>.
Watch the prompt
Commands in this chapter run on Windows. If your prompt says alex@homeserver:~$, you're still on the server; type exit first. Typing Windows commands on the server gives errors like command not found.
Step 1: Check SSH is installed#
ssh -V
You should see something like OpenSSH_for_Windows_9.5.
Step 2: First connection (with password)#
ssh alex@homeserver.local
Answer yes to the fingerprint question, type the server password, then exit.
Name not found?
Use the number instead: ssh alex@192.168.1.50. Use that number in the steps below too.
Step 3: Make a key#
ssh-keygen -t ed25519 -f "$env:USERPROFILE\.ssh\id_ed25519_homeserver" -C "windows-homeserver"
Choose a passphrase and save it in your password manager.
Step 4: Copy the public key to the server#
Windows has no ssh-copy-id, so use this one line instead (it's long, so copy it whole):
type "$env:USERPROFILE\.ssh\id_ed25519_homeserver.pub" | ssh alex@homeserver.local "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
Type the server password. No output means success.
Step 5: Create a shortcut#
notepad "$env:USERPROFILE\.ssh\config"
If Notepad asks to create the file, click Yes. Paste the following, then click File → Save:
Host homeserver
HostName homeserver.local
User alex
IdentityFile ~/.ssh/id_ed25519_homeserver
IdentitiesOnly yes
Check the file name
The file must be called config with no .txt at the end. If Notepad added .txt, rename the file in File Explorer (View → show file name extensions).
Step 6: Stop typing the passphrase every time#
Open PowerShell as administrator (right-click PowerShell → Run as administrator):
Set-Service -Name ssh-agent -StartupType Automatic
Start-Service ssh-agent
Close it. In a normal PowerShell:
ssh-add "$env:USERPROFILE\.ssh\id_ed25519_homeserver"
Type the passphrase once. Windows remembers the key, even after a restart.
Good to know
After this, anyone using your Windows account can use the key without the passphrase. Lock your PC when you walk away.
Step 7: Test#
ssh homeserver
Done when: ssh homeserver logs you in with no password prompt.
Next: 9. SSH from an iPhone (optional) or 10. Lock SSH