128 words
1 minute
SSH Key Management: A Complete Guide
Generating SSH Keys
# Ed25519 (recommended — fast, secure, short keys)ssh-keygen -t ed25519 -C "your@email.com"
# RSA 4096 (broader compatibility)ssh-keygen -t rsa -b 4096 -C "your@email.com"You’ll be prompted for a file location and passphrase. Always use a passphrase for production keys.
Managing Multiple Keys
Edit ~/.ssh/config to assign different keys to different hosts:
# Personal GitHubHost github.com HostName github.com User git IdentityFile ~/.ssh/id_ed25519_personal
# Work GitLabHost gitlab.work.com HostName gitlab.work.com User git IdentityFile ~/.ssh/id_ed25519_work
# Production serverHost prod HostName 203.0.113.50 User deploy IdentityFile ~/.ssh/id_ed25519_prod Port 2222Now you can simply ssh prod instead of typing the full command.
Adding Keys to the SSH Agent
# Start the agenteval "$(ssh-agent -s)"
# Add your keyssh-add ~/.ssh/id_ed25519
# On macOS, add to Keychainssh-add --apple-use-keychain ~/.ssh/id_ed25519Copying Public Keys to Servers
# The easy wayssh-copy-id -i ~/.ssh/id_ed25519.pub user@server
# Manual way (if ssh-copy-id is unavailable)cat ~/.ssh/id_ed25519.pub | ssh user@server \ "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"Security Best Practices
- Use Ed25519 keys — they’re more secure and performant than RSA
- Always set a passphrase — protects you if your key file is stolen
- Set proper permissions:
chmod 700 ~/.sshchmod 600 ~/.ssh/id_ed25519chmod 644 ~/.ssh/id_ed25519.pubchmod 600 ~/.ssh/config
- Disable password authentication on servers:
/etc/ssh/sshd_config PasswordAuthentication noPubkeyAuthentication yes - Rotate keys periodically — treat them like passwords
- Use
ssh-agentforwarding sparingly — it can be a security risk
Troubleshooting
# Test connection with verbose outputssh -vT git@github.com
# Check which key is being usedssh -v user@server 2>&1 | grep "Offering"
# Fix permission issueschmod 600 ~/.ssh/id_ed25519SSH keys are the foundation of secure remote access. Take the time to set them up properly, and you’ll save yourself countless headaches.
Share
If this article helped you, please share it with others!
SSH Key Management: A Complete Guide
https://blog.levifree.com/posts/ssh-key-management/ Some information may be outdated
Related Posts Smart
1
Web Security Essentials Every Developer Should Know
Security A practical overview of common web vulnerabilities — XSS, CSRF, SQL Injection, and more. Learn how to protect your applications.
2
Setting Up a Home Lab: A Beginner's Guide
Home Lab Build your own home lab for learning, self-hosting, and experimentation. From hardware choices to software stacks and network configuration.
3
Nginx Reverse Proxy: The Complete Setup Guide
DevOps Configure Nginx as a reverse proxy with SSL, load balancing, caching, and security headers. A production-ready setup guide.
4
Mastering the Linux Command Line
Linux Essential Linux commands every developer should know. From file management to process control, text processing, and networking.
5
Docker for Beginners: Containerize Everything
DevOps Learn the fundamentals of Docker — from images and containers to Dockerfiles and docker-compose. A practical guide to containerizing your applications.
Random Posts Random
1
Python Virtual Environments Explained
Programming 2026-06-19
2
Docker for Beginners: Containerize Everything
DevOps 2026-07-07
3
Understanding Git Branching Strategies
Developer Tools 2026-07-05
4
Web Security Essentials Every Developer Should Know
Security 2026-06-16
5
Introduction to WebSockets: Real-Time Communication
Web Dev 2026-05-28





