DEV Community

Cover image for πŸš€ GitHub SSH & "Repo Not Found": The Mistake That Took Me a Bit Too Long to Debug
Ishan Bagchi for Byte-Sized News

Posted on

πŸš€ GitHub SSH & "Repo Not Found": The Mistake That Took Me a Bit Too Long to Debug

β€œHi ishan1! You've successfully authenticated, but GitHub does not provide shell access.”

Sound familiar? It definitely did to me. πŸ™ƒ


🧩 The Confusing Error

So here I was, just trying to clone a private repository called the-project from GitHub using SSH:

git clone [email protected]:some-org/the-project.git
Enter fullscreen mode Exit fullscreen mode

And then this happened:

ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Enter fullscreen mode Exit fullscreen mode

At first, I thought:

  • Maybe I typed the repo name wrong.
  • Maybe it was deleted.
  • Maybe I lost access?

But nope β€” everything was perfectly fine on GitHub.

Just to be sure, I checked my SSH authentication:

ssh -T [email protected]
Enter fullscreen mode Exit fullscreen mode

It replied:

Hi ishan1! You've successfully authenticated, but GitHub does not provide shell access.
Enter fullscreen mode Exit fullscreen mode

Wait a second β€” ishan1? I was expecting ishan2 (the account that actually had access to the-project).


🀦 The Realization: SSH Was Using the Wrong GitHub Account

Turns out, my machine was authenticating with the wrong SSH key β€” the one tied to ishan1, my personal GitHub account, instead of ishan2, which was the one invited to collaborate on the private repository the-project.

So of course GitHub said β€œRepo not found” β€” from ishan1's perspective, it really didn’t exist!


πŸ› οΈ The Fix: Use the Right SSH Key for the Right GitHub Account

If you’re juggling multiple GitHub accounts like I am, here’s the fix that worked for me:

1. πŸ” Generate a new SSH key for the correct GitHub account (ishan2):

ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519_ishan2
Enter fullscreen mode Exit fullscreen mode

2. βž• Add that key to your SSH agent:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_ishan2
Enter fullscreen mode Exit fullscreen mode

3. πŸ“‹ Add the public key to the ishan2 GitHub account:

cat ~/.ssh/id_ed25519_ishan2.pub
Enter fullscreen mode Exit fullscreen mode

Then go to GitHub β†’ Settings β†’ SSH and GPG Keys β†’ New SSH Key, and paste it there.

4. 🧠 Set up a custom SSH host in ~/.ssh/config:

Host github-ishan2
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_ed25519_ishan2
Enter fullscreen mode Exit fullscreen mode

5. βœ… Clone the repo using the custom alias:

git clone git@github-ishan2:some-org/the-project.git
Enter fullscreen mode Exit fullscreen mode

Boom πŸ’₯ β€” this time, the correct SSH key was used, the correct GitHub identity (ishan2) was applied, and access to the private repo worked just like that.


🎯 Lesson Learned

I used to treat SSH as a one-time setup. Turns out, if you're managing multiple GitHub identities (say, ishan1 for personal and ishan2 for work or freelance), your config needs to be smart about which key to use.

If you get the "Repository not found" error while cloning a private repo, ask yourself:

  • Which GitHub user is this SSH key connected to?
  • Is it the right one?
  • Do I need a custom ~/.ssh/config setup?

✍️ Final Thoughts

SSH is amazing… until it silently logs you in as the wrong person πŸ˜…

If this post saves even one other developer from scratching their head for 30 minutes β€” it’s a win.

Feel free to copy this setup and tweak the names for your own accounts. In my case, it was ishan1 vs ishan2, and a private repo called the-project. Yours might be different, but the fix remains the same.

Top comments (0)

OSZAR »