Your key.
Your access.
Connect with SSH without exposing secrets. Public keys travel; private keys stay with you.
Two keys. Only one is shared.
Public key
The .pub file. Add this to your GitHub account so GitHub can recognize your key.
Private key
Keep this on your computer. Never paste it into GitHub, chat, a repository or a screenshot.
Passphrase
Protects the key file. It is not your GitHub password. Use a strong one and store it safely.
Check before you create
Look for existing SSH keys using your operating system's file browser or terminal. Do not overwrite a key you do not recognize. If you already have a suitable key, use the existing-key instructions in the official guide.
ssh-keygen -t ed25519 -C "YOUR_EMAIL"YOUR_EMAIL is a placeholder label. Run this on your own computer. Choose a new filename if a key already exists, and enter a secure passphrase when prompted. The command is sourced from GitHub docs, not a transcript of a key created by this page.
Exact steps for your system
pick one- Make the key. Use Git Bash or PowerShell. Press Enter for the default path, then choose a passphrase.
ssh-keygen -t ed25519 -C "you@example.com"- Start the ssh-agent. Open a new admin PowerShell window for this one step.
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Start-Service ssh-agent- In a normal (not admin) terminal, add the private key. Replace YOU with your Windows user name.
ssh-add c:/Users/YOU/.ssh/id_ed25519- Copy the public key. In Git Bash use the first line. In PowerShell use the second.
clip < ~/.ssh/id_ed25519.pub
cat ~/.ssh/id_ed25519.pub | clip- Make the key. Press Enter for the default path, then choose a passphrase.
ssh-keygen -t ed25519 -C "you@example.com"- Start the agent.
eval "$(ssh-agent -s)"- Open or create
~/.ssh/configand add this. If you chose no passphrase, leave out the UseKeychain line.
Host github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519- Add the private key to the agent and the Keychain.
ssh-add --apple-use-keychain ~/.ssh/id_ed25519- Copy the public key.
pbcopy < ~/.ssh/id_ed25519.pub- Make the key. Press Enter for the default path, then choose a passphrase.
ssh-keygen -t ed25519 -C "you@example.com"- Start the agent and add the private key.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519- Print the public key, then select and copy that one line.
cat ~/.ssh/id_ed25519.pubThen add the key on GitHub (Settings, SSH and GPG keys, New SSH key) and run ssh -T git@github.com. Steps follow GitHub's official guides, linked under Sources. If you made the key with another name, use that name instead of id_ed25519.
Add the public key to GitHub
- Open GitHub Settings, then SSH and GPG keys.
- Choose New SSH key.
- Give it a recognizable title, such as the device name.
- Choose Authentication Key for Git access.
- Paste the contents of the .pub file, not the private key.
- Add the key and complete any account verification.
Authentication and commit signing are different uses. Adding an authentication key does not make all your commits signed.
Spot the safe file
Which file is the public key?
Choose a filename.
Test without trusting blindly
ssh -T git@github.comOn the first connection, SSH may ask you to trust the host. Compare the fingerprint with GitHub's published fingerprints before accepting. The official test guide explains the expected response and why a successful authentication test can still exit with status 1.
The command above is a sourced example, not a test run for your account. We do not print invented authentication output. To use SSH for a repository, copy its SSH clone URL from GitHub's Code menu. If access fails, check account permissions and the key in use; do not share the private key to troubleshoot.
Practice: key, GitHub, test
hands-onMake a key pair, look at both files, meet the famous "Permission denied (publickey)", fix it, and clone over SSH. The key here is a practice key, not a real secret.
Loading
Quick check
1 / 3You finished the course
what nowYou can now do the whole loop on your own:
- Install Git, set your name and email, and start a repository.
- Stage, commit, read diffs and ignore files.
- Undo mistakes without losing work.
- Branch, merge and resolve a conflict.
- Clone, fetch, pull and push, and open a pull request.
- Connect to GitHub with an SSH key.
Where to go next
- Open the Lab and practice on a free repo.
- Keep the cheatsheet open while you work.
- Stuck on an error? The fix pages explain common ones.
- Read a short explainer when two commands look the same.
Try it on a real project this week. One small repo, one branch, one pull request.
Sources
Generate a key and configure the agent · Add the public key · Test the SSH connection · GitHub SSH fingerprints