26

I'm now using msysgit because of the GUI tools, which use Putty's Pageant and PLink utilities, but I use Cygwin as a general SSH terminal. I had been using ssh-agent on Cygwin, but that means I have to enter my SSH key passphrases for both SSH key managers. Is it possible to configure all my Unix-port tools (msys, git, cygwin, Ruby Net:SSH, etc.) to use PLink/Pageant instead of ssh-agent? It seems that's the kind of thing PLink was made for, but I can't find documentation on how.

Jerph
  • 369
  • 1
  • 4
  • 6
  • 3
    five years later: ["PuttyAgent now supports openssh/cygwin/msys"](http://niki.hammler.net/wiki/PuttyAgent_now_supports_openssh/cygwin/msys) – Tobias Kienzler Jan 08 '15 at 14:18

6 Answers6

17

I also wrote a proxy between openssh and pageant, which I call ssh-pageant. It looks like pretty much the same approach as charade, but I hadn't heard of it. Well in case you have trouble, I thought I'd throw out ssh-pageant to try instead.

Josh Stone
  • 271
  • 2
  • 3
11

I came across charade a while ago, which replaces ssh-agent and proxies to Pageant. At the time I couldn't quite get it working, and haven't had the chance to play with it since, but it might be worth a try. If you have any luck please post back and let me know, it's been on my list of things to do for ages!

Jon M
  • 246
  • 2
  • 8
  • I can confirm it works. (As can @Nightfly below) – Christopher Galpin May 17 '10 at 20:40
  • 2
    I would only add that before you build the package make sure that you have following packages in addition to default cygwin installation: `make`, `gcc-core`, `keychain`, `psmisc`, and of course `openssh`. This way if you follow very detailed instruction from the README file you will not get any errors – Alexander Pogrebnyak Sep 14 '10 at 15:49
5

You are looking to integrate ssh-agent and pageant so that you have only one keystore. One way you can do this is use PuTTY as your terminal, keep your keys in pageant, enable agent forwarding, run Cygwin sshd and ssh to localhost. This will give you an environment where keys are served by pageant over the ssh connection with PuTTY -- no need to run ssh-agent.

It should be possible to do the same with Plink. Just use the -A option, and use the resulting SSH_AUTH_SOCK setting in your interactive Cygwin sessions. Disclaimer: I have not tried this.

Edit: I have now tried this; it works just fine. I created a shortcut to PLINK:

"C:\path\to\PLINK.EXE" -A -ssh -l yournamehere localhost "echo $SSH_AUTH_SOCK; while :; do sleep 86400; done"

Then, in a Cygwin terminal (I use PuTTYcyg of course):

export SSH_AUTH_SOCK=/tmp/ssh-crYQh24AMq/agent.3964
ssh-add -l

Seems to work great, but still requires a local sshd.

What would be really great is to have an openssh-compatible agent which communicates directly to the pageant keystore, but this won't happen unless someone writes such a beast. I looked into it many moons ago, and it seemed more trouble than it was worth given that this work-around is easy enough.

  • mmm, this not a bad idea at all. It's probably how I'll go. Thanks! And regarding your openssh-compatible agent, yes that's exactly what I was hoping plink could provide. It seems like it would be a pretty high value piece of code, since so much work goes into making software (like git) compatible with both openssh and plink. Why not just have a translation layer? Seems like "the Unix way" to do it. :) – Jerph Jan 03 '10 at 16:32
2

Could you go the other way and use puttycyg?

[http://code.google.com/p/puttycyg/]

That way you have putty as your cygwin terminal.

gm3dmo
  • 9,632
  • 1
  • 40
  • 35
  • I'm not sure what the consequences of using putty would be for my Cygwin scripts. I'm not really clear on where puttycyg inserts itself, I guess. I'll look into it - thanks! – Jerph Jan 03 '10 at 16:27
0

Another way to do it.

Add this line at the very top of .bash_profile

exec ssh-agent /usr/bin/bash

Then add your keys at the bottom of .bashrc

ssh-add ~/.ssh/myprivate
ken
  • 101
0

i would suggest the same thing (use putty) but just use putty as it intergrates better with pagent and plink, i use it along with msysgit but use the git bash provided by msysgit and it would fine, its a little tedious switching between consoles but the seperation can be good as well

seanl
  • 470
  • 5
  • 13
  • I can't leave Cygwin, unfortunately. I depend on some of the packages it provides, not just pure ssh console stuff. Msys has its strengths ("better" integration with many Windows tools and the Windows version of Ruby, for instance) but it would be very difficult to migrate my Cygwin based scripts with the tools available on Msys. – Jerph Jan 03 '10 at 16:26