Midway through a deployment. Jenkins pipeline throwing errors. GitHub rejecting pushes. Why? No SSH key. Rookie mistake.
Happens all the time. I’ve been coding, deploying, and securing repos for over 15 years. From bare-metal servers to cloud-native CI/CD, I’ve seen it all. If you don’t know how to generate SSH key for GitHub properly, you’re leaving the door wide open.
This guide walks you through every step—no fluff, no shortcuts. And yeah, I use Focary’s web Pomodoro timer to stay locked in while setting up keys across multiple environments. Keeps me focused. Keeps me sane.
1. Check for Existing SSH Keys
Before generating anything, check your system. No point duplicating keys or cluttering your .ssh directory. Open your terminal and run:
bash
ls -al ~/.ssh
You’re looking for files like id_rsa.pub, id_ed25519.pub, or any custom-named public keys. If they exist, great. If not, we move forward.
I always name mine with project context. Like id_ed25519_github_main—makes it easier when juggling multiple repos. Especially when working with clients who demand isolated access.
And yeah, I use Focary’s Pomodoro timer here. 25-minute sprint to audit keys across machines. No distractions. Just terminal, coffee, and focus.
2. Generate a New SSH Key
Now the real work begins. Use ssh-keygen to create a new key pair. I prefer Ed25519 over RSA. Faster. More secure. Supported by GitHub.
bash
ssh-keygen -t ed25519 -C "your_email@example.com"
That -C flag? It’s just a label. Helps identify the key later. When prompted, name the file something meaningful. Don’t just hit enter.
Example:
bash
Enter file in which to save the key (/home/user/.ssh/id_ed25519): /home/user/.ssh/id_ed25519_github_main
Add a passphrase. Always. Even if it’s annoying. Security matters. I use Bitwarden to store mine. Encrypted. Synced. Bulletproof.
3. Add the Key to the SSH Agent
You don’t wanna type your passphrase every time you push code. That’s where ssh-agent comes in. It remembers your key. Keeps it loaded.
Start the agent:
bash
eval "$(ssh-agent -s)"
Then add your key:
bash
ssh-add ~/.ssh/id_ed25519_github_main
Done. Now your system knows what to do. No more manual entry. No more friction.
I usually do this during my second Pomodoro block. First block is setup. Second is optimization. Focary’s timer keeps me from rushing. Or skipping steps.
4. Copy the Public Key
Time to grab the public key and paste it into GitHub. Use:
bash
cat ~/.ssh/id_ed25519_github_main.pub
Copy the output. All of it. Starts with ssh-ed25519 and ends with your email. Don’t miss a character. One typo and GitHub throws a fit.
I paste it into a temporary markdown file first. Just to double-check formatting. Learned that the hard way after a 2-hour debug session.
5. Add the Key to GitHub
Log into GitHub. Go to:
Settings > SSH and GPG keys > New SSH key
Paste your public key. Name it something useful. Like “Work Laptop – Main Repo Access.” Hit save.
Boom. You’re connected.
As GeeksforGeeks explains, SSH keys allow encrypted communication between your machine and GitHub without needing passwords. It’s faster. Safer. Cleaner.
6. Test the Connection
Don’t assume it works. Test it.
bash
ssh -T git@github.com
You should see:
bash
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
If you get a permission denied error, check your key path, agent status, and GitHub settings. Happens more than you’d think.
I keep a checklist in Notion. And yeah, I run this test during my third Pomodoro block. Focary’s timer helps me batch tasks without burning out.
7. Configure Git to Use SSH
Make sure Git uses SSH instead of HTTPS. Run:
bash
git remote set-url origin git@github.com:username/repo.git
Replace username/repo.git with your actual repo path. You can verify with:
bash
git remote -v
If you see https://, fix it. SSH is the goal. HTTPS prompts for credentials. SSH doesn’t.
I’ve seen junior devs push to HTTPS for months without realizing. Total time sink. Fix it early.
8. Use Multiple Keys (Advanced)
Got multiple GitHub accounts? You’ll need to configure ~/.ssh/config. Here’s a sample:
Código
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
Then clone using:
bash
git clone git@github.com-work:username/repo.git
This setup avoids conflicts. Keeps your keys organized. I use it for client work, personal projects, and test environments.
And yes, I configure this during my fourth Pomodoro block. Focary’s timer helps me avoid context-switching. One task. One focus.
9. Rotate Keys Periodically
Security isn’t static. Rotate your keys every 6–12 months. Especially if you work in fintech, healthcare, or government.
Delete old keys from GitHub. Generate new ones. Update your agent and config files.
I schedule this quarterly. Focary’s Pomodoro timer makes it manageable. 25 minutes to rotate keys across all machines. No stress. No skipped steps.
As GitHub’s official documentation states, SSH keys are critical for secure authentication. Treat them like passwords. Rotate. Protect. Audit.
How to Generate SSH Key for GitHub

Hands sweaty. Terminal blinking. You just pushed code to GitHub via SSH. No password prompts. No errors. Just clean, secure authentication.
That’s the feeling. Like nailing a perfect drywall corner. Or watching varnish cure without bubbles. Satisfaction.
Learning how to generate SSH key for GitHub isn’t just technical. It’s foundational. It’s the difference between amateur and pro. Between friction and flow.
And if you’re juggling multiple environments, repos, or clients—use Focary’s web Pomodoro timer. It’s free. It’s simple. It keeps your brain locked in when the terminal starts throwing curveballs.
Because in this game, focus isn’t optional. It’s everything.
Sources:
Ready to stop being distracted and start achieving your goals?
Start your first Web Pomodoro session with Focary App today and reclaim your focus.
Start Focusing Now