PureTools

SSH Keys: Generate, Configure, and Manage Like a Pro

PureTools Team· 7 min read
SSH Keys: Generate, Configure, and Manage Like a Pro

SSH Keys: Stop Typing Passwords

SSH keys replace password authentication with cryptographic key pairs. You keep the private key on your machine, put the public key on the server (or GitHub), and never type a password again. It's both more secure and more convenient.

Generate a Key

# Ed25519 (recommended — fast, secure, short keys)
ssh-keygen -t ed25519 -C "your@email.com"

# RSA (legacy compatibility, if Ed25519 isn't supported)
ssh-keygen -t rsa -b 4096 -C "your@email.com"

You'll be prompted for a file location and passphrase. Use the default location (~/.ssh/id_ed25519) and always set a passphrase — it protects the key if your machine is compromised.

Add to GitHub

# Copy public key to clipboard
# macOS
pbcopy < ~/.ssh/id_ed25519.pub

# Linux
xclip -selection clipboard < ~/.ssh/id_ed25519.pub

# Windows
cat ~/.ssh/id_ed25519.pub | clip

Go to GitHub → Settings → SSH and GPG keys → New SSH key. Paste. Test:

ssh -T git@github.com
# Hi username! You've been successfully authenticated

SSH Agent (Don't Retype Your Passphrase)

# Start the agent
eval "$(ssh-agent -s)"

# Add your key (asks passphrase once)
ssh-add ~/.ssh/id_ed25519

# macOS: add to Keychain (persists across reboots)
ssh-add --apple-use-keychain ~/.ssh/id_ed25519

The SSH Config File

The power move. Create ~/.ssh/config:

# Personal GitHub
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_personal

# Work GitHub (different account)
Host github-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_work

# Production server
Host prod
  HostName 203.0.113.42
  User deploy
  IdentityFile ~/.ssh/id_ed25519
  Port 2222

# Jump host (bastion)
Host internal-db
  HostName 10.0.1.50
  User admin
  ProxyJump bastion

Host bastion
  HostName bastion.example.com
  User admin
  IdentityFile ~/.ssh/id_ed25519

Now instead of ssh deploy@203.0.113.42 -p 2222 -i ~/.ssh/id_ed25519, just type ssh prod.

For the work GitHub, clone with: git clone git@github-work:company/repo.git

Copy Key to Server

# The easy way
ssh-copy-id user@server

# Manual way
cat ~/.ssh/id_ed25519.pub | ssh user@server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

# Fix permissions (if login fails)
ssh user@server "chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"

Key Types Compared

TypeKey SizeSecurityCompatibility
Ed25519256 bits (fixed)ExcellentOpenSSH 6.5+ (2014)
RSA 40964096 bitsGoodUniversal
ECDSA256/384/521 bitsGoodOpenSSH 5.7+
DSA1024 bitsDeprecatedDon't use

Security Tips

  • Always use a passphrase on your private key.
  • Never share or commit your private key. The file without .pub is private.
  • Use different keys for different services (personal GitHub, work, servers).
  • Disable password auth on servers once SSH keys are set up: PasswordAuthentication no in /etc/ssh/sshd_config.
  • Rotate keys periodically, especially when team members leave.

Generate keys: Password Generator — create strong passphrases for your SSH keys.