4

After a lot of googling and troubleshooting, I believe I've determined that Cygwin doesn't send its SSH private key when SSHing unless you explicitly tell it to. I can do this in my SSH config file with the line IdentityFile, but I don't know how to get it to do this when using git too.

This time, I'm specifically trying to push to GitHub. My SSH key has been added. Previously, I couldn't SSH in until I set up my config file and added that IdentityFile line. Now I can successfully SSH into GitHub, but can't git push.

Anyone know how to get around this?

Thanks a ton!

Edit: To be clear, when I try to git push, I get the following error:

$ git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

But I can SSH just fine:

$ ssh github
Hi ______! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

Edit2 with solution:

User 'Cupcake' suggested adding my key to ssh-agent. I ran:

$ ssh-add <private key path>

And now it works. Thanks!

MattM
  • 1,159
  • 1
  • 13
  • 25
  • 1
    Could it be related to http://stackoverflow.com/a/16448080/6309? – VonC Aug 20 '13 at 06:48
  • 1
    Are you using a non-default name for your private key (i.e. not `id_rsa`)? Does your private key have a passphrase? Are you not using `ssh-agent`? Is there a reason that you're using Cygwin instead of msysgit? Cygwin's Git distribution is relatively very old (only 1.7.9, compared to msysgit 1.8.3). –  Aug 20 '13 at 06:50
  • Thanks Cupcake! I didn't know I needed to use ssh-agent. I added my private key with ssh-add and now it works! Edit: btw, I am using a non-default name for my private key...not sure whether that matters. No passphrase. I'm using Cygwin for my own convenience (or lack of knowledge of a 'better' option?)...I did notice Git is pretty outdated in Cygwin. – MattM Aug 20 '13 at 06:59
  • @PlanetLotus if your private key isn't encrypted, you shouldn't need to use `ssh-agent`. Is there a reason that you're not using the default name for a private key? Finally, have you tried the msysgit bash? It doesn't have as many features as Cygwin, but it's version of Git is significantly more up-to-date, and it still has a lot of Unix tools available. –  Aug 20 '13 at 15:19
  • Weird. I'm not using the default name because it helps me keep which computer it's associated with straight. I haven't tried msysgit bash, no. I had it installed for another project but hadn't really touched it other than that. If it's fully featured, I may have to give that another shot :) Thanks. – MattM Aug 20 '13 at 22:17
  • @Cupcake Hi I am having problem git push to ssh repo in cygwin. (but pull and clone is fine.) currently the `git --version` gives 2.1.0. Is there anyway to break down the problem see if it's connection or access right? – Weishi Z Sep 15 '14 at 04:12
  • @WeishiZeng if you can pull and clone, then that suggests to me that your problems pushing are due to access rights, not transferring data over SSH, but that's just a guess. Without more details like the URI you're using to connect to remote repos and other stuff like that, I can't really deduce anything more, and I haven't used Cygwin for a long while because they're Git distribution was so far behind the msysgit version. –  Sep 15 '14 at 19:22

1 Answers1

1

I personally use PuttyCyg to Putty directly into my Cygwin installation. This has the benefit of giving me access to Putty's ssh implementation, as well as Putty's terminal which I found to be more easily configurable and less buggy than Cygwin's.

For a list of instructions on how to set up PuttyCyg as well as some notes and configuration files see the effective-cygwin GitHub page.

alexgophermix
  • 4,189
  • 5
  • 32
  • 59