简体   繁体   中英

Git pull over SSH - Repository not found. HTTPS works

Git pull over ssh does not work for one of private repositories of my organization.

➜  player2-js git:(master) git remote set-url origin git@github.com:MyOrganization/player2-js
➜  player2-js git:(master) GIT_TRACE=1 git pull
11:24:39.494710 git.c:371               trace: built-in: git 'pull'
11:24:39.495491 run-command.c:350       trace: run_command: 'fetch' '--update-head-ok'
11:24:39.495882 exec_cmd.c:116          trace: exec: 'git' 'fetch' '--update-head-ok'
11:24:39.498051 git.c:371               trace: built-in: git 'fetch' '--update-head-ok'
11:24:39.499378 run-command.c:350       trace: run_command: 'ssh' 'git@github.com' 'git-upload-pack '\''MyOrganization/player2-js'\'''
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Url is correct, I copied it from github and double-checked it. And, of course my SSH access is correct, I also checked it:

➜  player2-js git:(master) ssh -T git@github.com                                                     
Hi MyOrganization/academy-ui! You've successfully authenticated, but GitHub does not provide shell access.

I also have no issues with other org's repos where I have same access permissions. Also my colleagues don't have errors with same repo. At the same time I'm able to normally load it through:

➜  player2-js git:(master) git remote set-url origin https://besuhoff@github.com/MyOrganization/player2-js
➜  player2-js git:(master) git pull
Password for 'https://besuhoff@github.com': 
Already up-to-date.

I've looked through Stack but found only cases where ones either had issues with public key or lacked permissions for repo, both of which are not my cases.

What can it be?

UPD. Thanks to @Jakuje, I've found out that I was using improper key. For anyone running in the same pretty specific and weird case I'm posting steps to reproduce:

  1. Initial state, everything works throught ssh
  2. I created a new key file through ssh-keygen, placed it into my .ssh folder
  3. I authorized the newly created key to access one of my repositories
  4. My console git client began using this new key when authorizing to git@github.com via ssh (how come? Does ssh-keygen add to ssh-agent or something???)

Maybe I'm wrong, but your url does not contain a protocol. So the default protocol should jump in, that woudl be git://, not ssh://.

But as I said, I'm not sure about it. But's worth a try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM