Adding an Ed25519 SSH Key for Remote Access
This guide walks you through generating an Ed25519 SSH key on Windows and adding it to a remote Ubuntu machine for SSH access.
Part 1: Generate the Ed25519 Key on Windows
- Open PowerShell (or Windows Terminal)
-
Generate the SSH key
:
ssh-keygen -t ed25519 -C "your-email@example.com"
-
When prompted for a file location
, press Enter to accept the default location (
C:\Users\YourUsername.ssh\id_ed25519
) or specify a custom path. - When prompted for a passphrase , enter a secure passphrase or press Enter twice for no passphrase (less secure but more convenient).
-
Verify your key was created
:
dir $env:USERPROFILE.ssh
id_ed25519
(private key) andid_ed25519.pub
(public key). -
View your public key
:
Get-Content $env:USERPROFILE.ssh\id_ed25519.pub
Part 2: Add the Public Key to Your Ubuntu Server
Option 1: Using ssh-copy-id (if installed on Windows)
If you have ssh-copy-id available on your Windows machine:
ssh-copy-id -i $env:USERPROFILE.ssh\id_ed25519.pub username@ubuntu-server-ip
Option 2: Manual Method
-
Copy your public key to clipboard
:
Get-Content $env:USERPROFILE.ssh\id_ed25519.pub | clip
-
Connect to your Ubuntu server
:
ssh username@ubuntu-server-ip
-
On the Ubuntu server, create/modify the authorized_keys file
:
mkdir -p ~/.ssh chmod 700 ~/.ssh touch ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
-
Add your public key to authorized_keys
:
echo "PASTE_YOUR_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys
-
Exit the server
:
exit
Part 3: Test Your Connection
ssh username@ubuntu-server-ip
You should now connect without requiring a password (unless you set a passphrase on your SSH key).
Troubleshooting
-
If connection fails, check SSH service:
sudo systemctl status ssh
on Ubuntu -
Verify file permissions:
chmod 700 ~/.ssh
andchmod 600 ~/.ssh/authorized_keys
-
Check SSH server config:
/etc/ssh/sshd_config
should havePubkeyAuthentication yes
-
Review SSH logs:
sudo tail -f /var/log/auth.log
on Ubuntu while attempting to connect
Ed25519 keys provide excellent security with shorter key lengths than RSA, making them both more secure and more convenient.
No comments:
Post a Comment