β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
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.
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]
It replied:
Hi ishan1! You've successfully authenticated, but GitHub does not provide shell access.
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
2. β Add that key to your SSH agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_ishan2
3. π Add the public key to the ishan2
GitHub account:
cat ~/.ssh/id_ed25519_ishan2.pub
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
5. β Clone the repo using the custom alias:
git clone git@github-ishan2:some-org/the-project.git
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)