4

I've set up my local system for working with GitHub how descrided in the "Generating SSH Keys" How-To.

The key files and the known_hosts have been created, the public key has been added to the GitHub account, and I get the message "Hi ***! You've successfully authenticated, but GitHub does not provide shell access."

enter image description here

But all my attempts to do something, what needs a connection to the server (EDIT: with writing access) -- git clone, git push etc. -- end with an error:

fatal: The remote end hung up unexpectedly

EDIT:

I can clone, but only via HTTP (https://github.com/account/reponame.git) or Git Read-Only (git://github.com/account/reponame.git).

EDIT:

***@**** ~/.ssh
$ ssh-add -l
Could not open a connection to your authentication agent.

Although an ssh-agent daemon (ssh-agent.exe) is running.

Probably that is the problem.

automatix
  • 14,018
  • 26
  • 105
  • 230

2 Answers2

2

The only instance where that error message pops up, while your public ssh key is correctly recorded by GitHub, is when

  • you try to clone a repo with a wrong case or an improper ssh url.
    It should be:
git clone git@github.com:user/repo.git
  • you try to clone a repo for which you don't have write access (public repo), or any access (private repo).
    From the GitHub page "Which remote URL should I use?"

To use these URLs, you must have write access to a public repo or any access to a private repo.
These URLs will not work with a public repo you do not have write access to.

  • the private key is passphrase protected and your authentication agent doesn't run properly:
$ ssh-add -l
Could not open a connection to your authentication agent.

For the last case, consider "How to run (git/ssh) authentication agent?" or "ssh-add complains: Could not open a connection to your authentication agent"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • No, the mistake is somewhere else: It's my repo (so, I should have full acces to it) and I'm using the right SSH URL (copied from the GitHub website). – automatix Feb 27 '13 at 09:36
  • @automatix are you using a preivate key protected by a passphrase? – VonC Feb 27 '13 at 10:20
  • I've tried both -- with and without passphrase. The result is the same. – automatix Feb 27 '13 at 10:22
  • @automatix what is the value of your GIT_SSH environment variable ? (as in http://stackoverflow.com/a/5315762/6309). Does it reference plink.exe (as in http://gitolite.com/gitolite/putty.html)? – VonC Feb 27 '13 at 10:26
  • It reference `C:\Program Files\TortoiseGit\bin\TortoisePlink.exe` – automatix Feb 27 '13 at 10:35
  • I've changed the GIT_SSH, so that it reference `C:\Program Files (x86)\PuTTY\plink.exe`. Now the output is a little bit different, but it seems to be caused by the same error: `Unable to open connection: Network error: Cannot assign requested address fatal: The remote end hung up unexpectedly` – automatix Feb 27 '13 at 10:43
  • @automatix do you have the same issue in a `git-cmd` session ((instead of a git bash)? – VonC Feb 27 '13 at 12:46
  • I don't use `git-cmd`, but I have the same issue in `git bash` and (standrad Windows) cmd and also in TortoiseGit. – automatix Feb 27 '13 at 13:05
  • @automatix try and see if the issue persists with `git-cmd` (which is part of msysgit) – VonC Feb 27 '13 at 13:18
  • I've just treid ti with the "Git Shell" downloaded from [GitHub](http://windows.github.com/) (Windows Power Shell) -- and it has worked! Why is it working in the Git Shell and not working other tools??? – automatix Feb 27 '13 at 13:19
  • Yes, you are right -- it's working in `git-cmd`. But why is it not working in the standard Windows `cmd` and other tools like `TortoiseGit` and `Git Bash`? – automatix Feb 27 '13 at 13:23
  • After I've tried it in several clients, I'd like to resume the current status: It's working in **Git Shell** (Windows Power Shell, downloaded from GitHub), **msysGit** (msys.bat), and **git-cmd** (that is part of msysGit). But it's still not working in **cmd** (the standard Windows command line), **Git Bash**, and with **TortoiseGit**. – automatix Feb 27 '13 at 14:08
  • It is also not working in the **GNOME Terminal** of my Debian VirtualMashine (but with another error: `ssh: Could not resolve hostname github.com: Name or service not known` \\ `fatal: The remote end hung up unexpectedly`). – automatix Feb 27 '13 at 14:10
  • @automatix The Git Shell of "GitHub for Windows" is a Powershell one. The "git-cmd" of msysgit set a lot more environment variable than the git bash. In all cases, check the environment variables: they will make the difference. – VonC Feb 27 '13 at 14:14
2

It works!

I've started the Pageant (PuTTY SSH authentication agent) and added my PuTTY private key id_rsa.pkk (exported with PuTTYgen (PuTTY Key Generator) from id_rsa) to it. Now I can write to my repos.

A small how-to for everyone, who has the same troubles I had:

0) Set up the local system for working with GitHub, how descrided in the "Generating SSH Keys" How-To.

1) Open PuTTYgen, load/import the (OpenSSH) private key id_rsa and save it (button Save private key) as id_rsa.pkk (in the same folder, where id_rsa is saved, -- ~/.ssh). You need this PuTTY variant of the key for PuTTY authentification with Pageant and (if you use it) TortoiseGit.

enter image description here

2a) Open Pageant (on my computer it's C:\Program Files (x86)\PuTTY\pageant.exe) and add the PuTTY private key. Or just open the PuTTY private key file (id_rsa.pkk) with Pageant.

2b) For TrtoiseGit I had only to set the SSH client (C:\Program Files (x86)\Git\bin\ssh.exe) in the global TrtoiseGit settings.

enter image description here

That's it.

I've got it working, but I don't have a deep understanding of this thema and cannot provide a low level explanation of the solution and the causes of this problem (and e.g why it was working in some clients and wasn't in some others). So feel free to edit/comment this post, if you can explain all this better.

automatix
  • 14,018
  • 26
  • 105
  • 230