This guide describes how to set up SSH key-based authentication to a Raspberry Pi using Windows PowerShell.
Open Windows PowerShell and run:
ssh-keygen -t ed25519 -C "your_email@example.com"
Press Enter to accept the default path (C:\Users\YourName.ssh\id_ed25519).
Optionally enter a passphrase for extra security.
Display the public key to copy it:
type $env:USERPROFILE\.ssh\id_ed25519.pub
Copy the entire output line. It should start with ssh-ed25519.
Create the .ssh Directory on the Pi
mkdir -p ~/.ssh
chmod 700 ~/.ssh
Open the file
nano ~/.ssh/authorized_keys
In the editor, paste the entire public key
chmod 600 ~/.ssh/authorized_keys
Confirm configuration:
sudo nano /etc/ssh/sshd_config
Ensure the following lines are set:
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication yes
sudo systemctl restart ssh
ssh username@<ip_address>
It should connect without a password prompt
After confirming key-based login works, you can improve security by disabling password login:
sudo nano /etc/ssh/sshd_config
set:
PasswordAuthentication no
Restart SSH
sudo systemctl restart ssh
If key authentication fails, test with verbose output:
ssh -vvv username@<ip_address>
Ensure correct permissions on the Pi:
~/.ssh directory: 700
~/.ssh/authorized_keys: 600
Do not delete your private key (id_ed25519) on your Windows machine.