How to add SSH key to GitHub
Adding SSH keys to GitHub enables secure, passwordless authentication for pushing and pulling code without entering credentials. As the creator of CoreUI with over 25 years of development experience, I’ve configured GitHub SSH access for countless team members and projects. The most effective solution is to copy your public SSH key and add it through GitHub’s web interface. This approach provides immediate access with strong cryptographic authentication.
Add your SSH public key to GitHub for secure authentication.
# Display your public key
cat ~/.ssh/id_ed25519.pub
# Copy public key to clipboard (macOS)
pbcopy < ~/.ssh/id_ed25519.pub
# Copy public key to clipboard (Linux with xclip)
xclip -selection clipboard < ~/.ssh/id_ed25519.pub
# Copy public key to clipboard (Windows/Git Bash)
cat ~/.ssh/id_ed25519.pub | clip
After copying your public key, follow these steps:
- Go to GitHub.com and sign in
- Click your profile photo, then Settings
- In the sidebar, click “SSH and GPG keys”
- Click “New SSH key” or “Add SSH key”
- In the “Title” field, add a descriptive label (e.g., “Work Laptop”)
- Select “Authentication Key” as the key type
- Paste your public key into the “Key” field
- Click “Add SSH key”
- Confirm your GitHub password if prompted
# Test SSH connection to GitHub
ssh -T [email protected]
# Expected output:
# Hi username! You've successfully authenticated, but GitHub does not provide shell access.
# Clone repository using SSH
git clone [email protected]:username/repository.git
# Change existing repository to SSH
git remote set-url origin [email protected]:username/repository.git
The SSH key authenticates your machine to GitHub without passwords. The title helps identify which device the key is from when you have multiple keys. Only add your public key (ending in .pub), never your private key. After adding the key, test the connection with ssh -T [email protected]. You should see a success message confirming authentication.
Best Practice Note
This is the same SSH key setup we use for CoreUI team members accessing GitHub repositories. Use descriptive titles for each key to easily manage and identify them. Remove keys from devices you no longer use. For enhanced security, enable two-factor authentication on your GitHub account in addition to SSH keys.



