Windows – Setting up Git over SSH on Windows using a non-standard port

gitputtysshwindows

I had to switch from Ubuntu so that I could use Adobe Suite at full speed and now I'm finding that SSH on windows is not as unified as on linux.

So I installed msysgit and putty but I'm finding that git is having trouble using putty for SSH. (I did install msysgit on the windows path and using plink).

I am trying to add a remote on my git project now to a server on a non-standard port by using a /.ssh/config file like

Host 255.255.255.255
Port 22222

Then I add the data to my git repo:

git remote add origin user@255.255.255.255:~/git/repo

But when I try to push I get an error message.

$ git push origin master
FATAL ERROR: Network error: Connection refused
fatal: The remote end hung up unexpectedly

So then I tried just using SSH from the git console:

ssh user@255.255.255.255

Which prompts me for my private key passphrase (which it doesn't have) and when I fail at that it asks me for my SSH user password (which works).

Since I am going to disable SSH login by password I need git to start using my key correctly.

Best Answer

I have a similar workflow but use gitosis to manage the repo on my VPS.

I use the msysgit bash with the windows path and plink as you suggest above but in addition I use pagent to manage the SSH key.

To access my repos this is the order I take,

  • Open Pagent and access my key (you only enter the passphrase here once if you have one and even if you do it remembers it for the whole session).
  • Then open Git bash and add/commit/push/pull/clone as normal.

One caveat I will note is that I had to convert the key I created with the Git bash using Putty Gen (available on the same link above) so that Pagent could use it.