Creating Secure SSH Keys: Ed25519 Instead of RSA
/ 1 min read
Table of Contents
Traditional RSA keys (especially 2048-bit ones) are now considered insufficiently secure or too cumbersome. The modern security standard is the Ed25519 algorithm.
Why Ed25519?
- Security: Higher security than RSA 4096 with a much shorter key length.
- Speed: Key generation and signature verification are significantly faster.
- Compactness: An Ed25519 public key is only 68 characters long.
How to Generate a Key
Open a terminal on your computer (macOS, Linux, or Windows PowerShell) and run the following command:
ssh-keygen -t ed25519 -C "your_email@example.com"Parameter Breakdown:
-t ed25519: Specifies the algorithm type.-C "...": Adds a text comment (usually your email) to help you identify the key in authorized lists.
Creation Process
- The system will ask for a location to save the key. Press
Enterto use the default (~/.ssh/id_ed25519). - Enter a passphrase. This is highly recommended: even if your key file is stolen, an attacker cannot use it without the passphrase.
Using the Key
Adding to a Server
Use the ssh-copy-id utility:
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server_ipViewing the Public Key
To add the key to GitHub, GitLab, or Bitbucket, copy its content:
cat ~/.ssh/id_ed25519.pubConclusion
If you are still using RSA, now is the time to regenerate your keys. It is not only more secure but also prevents issues with newer OpenSSH versions where older RSA types are disabled by default.