SSH Keys
SSH Key Generation Guide
Open Terminal
Open Terminal application
Generate ED25519 Key Pair
Run the following command to generate a key. When prompted for the save location, press Enter to use the default path. Then set a passphrase (optional but recommended).
ssh-keygen -t ed25519 -C "your_email@example.com"Start SSH Agent
SSH Agent manages keys so you don't need to enter your passphrase every time.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Copy Public Key
The public key needs to be added to the remote server or Git platform (e.g., GitHub).
cat ~/.ssh/id_ed25519.pubAdd Public Key to Remote Server
Use ssh-copy-id to add the public key to a remote server with one command.
ssh-copy-id user@hostnameVerify Connection
Verify that the key configuration is working.
ssh -T user@hostnameSSH Config File Template Generator
Auto-generate ~/.ssh/config configuration
Host myserver
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yesCommon SSH Commands Reference
ssh-keygen -t ed25519 -C "email"Generate Ed25519 key pair
cat ~/.ssh/id_ed25519.pubDisplay public key content for copying
ssh-copy-id user@hostAdd public key to remote server
eval "$(ssh-agent -s)"Start SSH Agent background process
ssh-add ~/.ssh/id_ed25519Add private key to SSH Agent
ssh-add -lList loaded keys
ssh -T git@github.comTest GitHub SSH connection
ssh -vT user@hostVerbose mode to troubleshoot connection issues
ssh-keygen -lf ~/.ssh/id_ed25519.pubView public key fingerprint
ssh-keygen -p -f ~/.ssh/id_ed25519Change private key passphrase
ssh-keygen -p -m PEM -f ~/.ssh/id_rsaConvert key to PEM format
ssh -R 8080:localhost:80 user@hostForward remote port to local
🔒 Security Tips & Best Practices
🔑 Use Ed25519
Ed25519 is more secure and faster than RSA, with shorter keys. Choose Ed25519 unless the target system does not support it.
🛡️ Set a Passphrase
Set a passphrase for your private key. Even if the private key file is leaked, a passphrase prevents attackers from using it directly.
📁 Set Correct Permissions
Private key file permissions should be 600 (chmod 600), and the .ssh directory should be 700. Never share your private key.
🔄 Rotate Keys Regularly
It is recommended to rotate SSH keys every 1-2 years, and immediately after any suspected compromise.
🚫 Disable Password Login
After setting up SSH keys, disable password-based login on the server (PasswordAuthentication no).
📋 Use Separate Keys
Use different keys for GitHub, work servers, and personal servers for easier management and revocation.
SSH Key Generation Guide
Main Features
- Step-by-step Guide - Guided SSH key pair generation
- Multi-platform - Linux/macOS, Windows PowerShell, Git Bash
- Config Generator - Auto-generate SSH config file templates
- Command Reference - Quick reference for common SSH commands
Use Cases
- GitHub/GitLab SSH authentication setup
- Passwordless remote server login
- DevOps automated deployment
- Multi-server SSH management