user1104539
user1104539

Reputation: 51

How do I isolate problems with ssh-add/ssh-agent provided in the msys implementation that comes with msysgit?

I have installed msysgit: Git-1.7.8-preview20111206.exe from http://code.google.com/p/msysgit/downloads/list (Edit: I have also installed msysGit-fullinstall-1.7.8-preview20111206.exe, which conveniently installs to a different directory, and I am seeing the same problems with that instance).

And I am having a problem with ssh-agent, where ssh-add always reports: "Could not open a connection to your authentication agent."

Unfortunately, ssh-add does not give me any further details on the error it encountered. It feels like it is timing out when it tries to connect to a socket, but it does not actually admit that this is the issue, and ssh-agent acts like it is running normally. Thinking about this combination makes me suspect a permissions issue, but I have no idea where I would look to investigate that kind of problem (and I do no see anything that I recognize as significant in windows event log).

This error message baffles me: I have reason to believe that I could get this error message if my environmental variables were not set up properly, but I have reason to believe that I have my environmental variables set properly. I have reason to believe that I could get this error message if my environmental variables refer to an instance of ssh-agent which is not running, but I have exactly one instance of ssh-agent running and it matches what I see in the environmental variables. And this is repeatable. I have started (and eventually shut down) dozens of instances of ssh-agent, using techniques like ssh-agent > ~/.ssh/environment; . ~/.ssh/environment, and eval `ssh-agent` and ssh-agent bash and so on... and I cannot get msys ssh-add to connect to msys ssh-agent.

bash-3.1$ ps | grep ssh-agent
    10304       1   10304      10304    ?  500 09:01:24 /bin/ssh-agent
bash-3.1$ bash -c 'set | grep SSH_A'
BASH_EXECUTION_STRING='set | grep SSH_A'
SSH_AGENT_PID=10304
SSH_AUTH_SOCK=/tmp/ssh-oAFwa11048/agent.11048
bash-3.1$ time ssh-add -L
Could not open a connection to your authentication agent.

real    0m10.730s
user    0m0.000s
sys     0m0.015s
bash-3.1$ wc /tmp/ssh-oAFwa11048/agent.11048
      0       3      52 /tmp/ssh-oAFwa11048/agent.11048
bash-3.1$ cat /tmp/ssh-oAFwa11048/agent.11048; echo
!<socket >59261 060A4541-9831B739-519220DE-57936738
bash-3.1$

I am not concerned with scripting anything, just yet -- I believe that if I can get ssh-add working from the command line that I can script it...

And note also that the 10 seconds of real time that ssh-add uses happens before it issues the "Could not open..." message.

And, I am using a current version of windows 7, here. And, I also have cygwin installed, but it's not in my path when I am using msys. Task manager shows me that I only have one instance of ssh-agent running. The ssh-agent which is running is the msys ssh-agent, and was started from msysgit's bash prompt (without anything from cygwin in path). The ssh key was generated using cygwin's ssh-keygen, but superficial testing shows me that msys ssh utilities have no problem with the file. ssh-agent does not give me any error messages or warnings.

I can use cygwin's ssh-agent, but mixing cygwin and msys introduces other complexities (and you can see some of that just from my description of this issue), and I am trying to get msys working without anything from cygwin.

What do I need to do to find out why the msys ssh-add does not work? (Or: what do I need to do to get that ssh-add to work properly?)

Upvotes: 5

Views: 2760

Answers (1)

HulkingUnicorn
HulkingUnicorn

Reputation: 597

I can't tell you much about the why's and how's, but I can tell you what I tried and what finally solved it. In git bash:

exec ssh-agent bash

Then (in the changed shell):

ssh-add

That worked to a degree, I only had to type the passphrase once, but I lost the normal look. After some more searching I found a .bashrc script on this Github help page.

Upvotes: 5

Related Questions