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 git@github.com: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 git@github.com
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 "ishan2@example.com" -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)