Complete guide to SSH key generation, configuration, agent setup, multi-account management, and troubleshooting for GitHub, GitLab, and server access.
Use when the user asks about ssh key manager, related techniques, best practices, or needs guidance in this domain.
Do NOT use when the request is outside the scope of ssh key manager or requires a different specialized skill.
Complete guide to SSH key generation, configuration, agent setup, multi-account management, and troubleshooting for GitHub, GitLab, and server access.
Use when the user asks about ssh key manager, related techniques, best practices, or needs guidance in this domain.
Do NOT use when the request is outside the scope of ssh key manager or requires a different specialized skill.
You are an SSH configuration specialist. Help the user generate, configure, and manage SSH keys for secure access. Provide exact commands and config file contents. Cover common platforms.
When to Use
Use this skill when:
User asks about ssh key manager techniques or best practices
User needs guidance on ssh key manager concepts
User wants to implement or improve their approach to ssh key manager
Do NOT use when:
The request falls outside the scope of ssh key manager
User needs a different specialized skill for their specific situation
The topic requires professional consultation beyond general guidance
# Copy public key to clipboard# macOS:
pbcopy < ~/.ssh/id_ed25519.pub
# Linux:
xclip -sel clip < ~/.ssh/id_ed25519.pub
# Windows:
clip < ~/.ssh/id_ed25519.pub
# Or just display it:
cat ~/.ssh/id_ed25519.pub
Go to GitHub > Settings > SSH and GPG keys > New SSH key
Paste the public key
Test: ssh -T git@github.com
Expected success message: Hi username! You've successfully authenticated
GitLab
Go to GitLab > Preferences > SSH Keys
Paste the public key
Test: ssh -T git@gitlab.com
Bitbucket
Go to Bitbucket > Personal settings > SSH keys
Paste the public key
Test: ssh -T git@bitbucket.org
Multi-Account SSH Config
~/.ssh/config for Multiple GitHub Accounts
# Personal GitHub
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
IdentitiesOnly yes
# Work GitHub
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
IdentitiesOnly yes
# Self-hosted GitLab
Host gitlab.company.com
HostName gitlab.company.com
User git
IdentityFile ~/.ssh/id_ed25519_work
Port 22
Update remotes to use the alias:
# Personal repos
git remote set-url origin git@github.com-personal:username/repo.git
# Work repos
git remote set-url origin git@github.com-work:orgname/repo.git
Server Access Config
# Production server
Host prod
HostName 203.0.113.10
User deploy
IdentityFile ~/.ssh/id_ed25519_prod
Port 22
# Jump host / bastion
Host bastion
HostName bastion.company.com
User admin
IdentityFile ~/.ssh/id_ed25519_work
# Server behind bastion
Host internal-server
HostName 10.0.1.50
User admin
ProxyJump bastion
# Wildcard for all company servers
Host *.company.com
User admin
IdentityFile ~/.ssh/id_ed25519_work
ServerAliveInterval 60
Key Management
List Current Keys
# List keys loaded in agent
ssh-add -l
# List all key files
ls -la ~/.ssh/
# Check key fingerprint
ssh-keygen -lf ~/.ssh/id_ed25519.pub
Change Passphrase
ssh-keygen -p -f ~/.ssh/id_ed25519
Remove a Key from Agent
ssh-add -d ~/.ssh/id_ed25519 # remove specific key
ssh-add -D # remove all keys
# Step 1: Verify your key is loaded
ssh-add -l
# Step 2: Test with verbose output
ssh -vT git@github.com
# Step 3: Check which key is being offered# Look for"Offering public key" lines in verbose output
# Step 4: Verify the right key is on the remote# Compare fingerprints:
ssh-keygen -lf ~/.ssh/id_ed25519.pub
# with what's registered on GitHub/GitLab
Common Fixes
Problem
Fix
Key not loaded
ssh-add ~/.ssh/id_ed25519
Wrong key offered
Add IdentitiesOnly yes to config
Permissions too open
chmod 600 ~/.ssh/id_ed25519
Agent not running
evaluate "$(ssh-agent -s)"
Wrong remote URL
git remote -v then fix with set-url
Firewall blocking port 22
Use HTTPS URL or SSH over port 443
SSH Over HTTPS Port (GitHub Firewall Workaround)
# ~/.ssh/config
Host github.com
HostName ssh.github.com
Port 443
User git