Linux ssh keygen Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux ssh-keygen Guide
Complete beginner-friendly guide to ssh-keygen on Linux, covering Arch Linux, CachyOS, and other distributions including SSH key generation, key pair creation, and secure authentication.
Table of Contents
ssh-keygen Basics
Generate Key
Basic usage:
# Generate SSH key
ssh-keygen -t ed25519
# -t = type (ed25519 recommended)
With Email
Add comment:
# With email comment
ssh-keygen -t ed25519 -C "[email protected]"
# -C = comment
Generating Keys
RSA Key
RSA keypair:
# Generate RSA key
ssh-keygen -t rsa -b 4096
# -t = type (RSA)
# -b = bits (4096 recommended)
ED25519 Key
ED25519 keypair:
# Generate ED25519 key (recommended)
ssh-keygen -t ed25519
# ED25519 is faster and more secure
Key Types
Key File Location
Default location:
# Keys stored in:
~/.ssh/id_ed25519 # Private key
~/.ssh/id_ed25519.pub # Public key
Custom Location
Custom path:
# Custom location
ssh-keygen -t ed25519 -f ~/.ssh/my_key
# -f = file (custom filename)
Key Management
View Public Key
Show public key:
# Display public key
cat ~/.ssh/id_ed25519.pub
# Copy this to add to servers
Copy to Server
Add to server:
# Copy public key to server
ssh-copy-id user@server
# Or manually:
cat ~/.ssh/id_ed25519.pub | ssh user@server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Troubleshooting
Permission Errors
Fix permissions:
# Set correct permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub
Summary
This guide covered ssh-keygen usage, SSH key generation, and key management for Arch Linux, CachyOS, and other distributions.
Next Steps
- SSH Configuration - SSH setup
- ssh-agent Guide - Key agent
- Security Configuration - Security setup
- ssh-keygen Documentation:
man ssh-keygen
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.