Wednesday, May 1, 2013

Git Extensions failing to connect to remotes with ssh due to FATAL ERROR: Network error: Connection timed out

Recently our git repo switched to ssh only - which was easy enough to deal with with git.  But I was having trouble getting Git Extensions to talk to the remote repo.  Each time I tried to do a push or pull I would get an error

"c:\Program Files (x86)\Git\bin\git.exe" pull --progress "origin"
FATAL ERROR: Network error: Connection timed out
fatal: Could not read from remote repository.

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

First check the obvious - you have the URL to the repo correct, and there are no firewalls blocking you.  Easy test.. use putty and open a ssh session to the hostname.  If you get prompted for login info - you're good.

Second, you must confirm your ssh keys and authentication are working correctly.  You can confirm this with putty and setting the session to login with username 'git' and use your ssh key (Under SSH->Auth in putty).  When Git Extensions is configured to use Putty for ssh, if you load the ssh key in the 'Manage Remotes' page, it will load the Putty Agent for you automatically as required for Git Extensions to work.

I was able to test all of that.. yet Git Extensions would not work.  The tip was that when I used the 'test connection' button in Git Extensions Manage Remotes.. I saw it used the plinkexecutable to test the connection.  So I ran plink directly and found if I did 'plink -T git@hostname' - the connection failed.  Eventually I tried the various parameters for plink, and found if I forced the connection to use -ssh  it worked.  But why did it not work in Git Extensions?

The conclusion is that even tho Git Extensions uses a local binary of plink for it's uses - plink will still rely on the putty session defaults defined in the user's windows profile.  In my case, for other work, I had configured Putty's default session to use telnet and not ssh (which is the default).  This in turn caused plink to NOT default to ssh - breaking Git Extensions which doesn't (as of 2.44) force plink to use ssh.

Solution - open Putty, set radio button to ssh for protocol, select 'default session' and click Save.  Now plink will use ssh by default and Git Extensions will work again! 

No comments: