π Secure SSH Connections in 2025
In the past, SSH connections were commonly secured using RSA keys. But as of 2025, that algorithm is considered outdated. The modern alternative is ed25519 β a compact, fast, and secure cryptographic algorithm thatβs now widely adopted.
π Generating an ed25519 Key
Open your terminal and run:
ssh-keygen -t ed25519 -C "your_email@example.com"
Parameter breakdown:
- -t ed25519 β sets the key type
- -C β adds a comment, typically your email (used for identification)
π Why include your email?
The email is stored in the public key as a comment. It helps you identify which key is which β especially useful if you manage multiple keys (e.g., personal, work, automation).
π What Youβll See:
Enter file in which to save the key (/home/you/.ssh/id_ed25519): [press Enter]
Enter passphrase (empty for no passphrase): [enter a password if you want]
Enter same passphrase again: [confirm it]
π Is a passphrase required?
Not strictly, but itβs highly recommended. If someone steals your private key, they still wonβt be able to use it without the passphrase β an extra layer of protection.
π Where the Keys Are Saved
- ποΈ Private key: ~/.ssh/id_ed25519
- π Public key: ~/.ssh/id_ed25519.pub
Important:
- The private key stays on your machine and must never be shared
- The public key is like a lock β you can place it anywhere (GitHub, servers, etc.)
π§© Setting Up SSH Access on the Server
First, copy your public key to the clipboard:
cat ~/.ssh/id_ed25519.pub
Then connect to your server using a password (as usual), and run:
mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys
Paste your public key into the file on a new line.
π Set the Correct Permissions
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
π Test Key-Based Login
Now try logging in without a password:
ssh user@ip
If it works β youβre good to go! π
If it doesnβt, stop here β do not proceed until youβre sure key-based login is working, or you risk losing access to your server.
π (Optional but Recommended) Disable Password Login
Open the SSH configuration file:
sudo nano /etc/ssh/sshd_config
Find and update the following lines:
PasswordAuthentication no
PermitRootLogin no
Then restart SSH:
sudo systemctl restart ssh
β Done!
Β
Youβre now using a modern, secure SSH setup based on ed25519. Your server no longer allows password-based logins, making it more resistant to brute-force attacks πͺ