When you run Git for the first time over ssh you'll probably be greeted with this:

image

This is no good if this command is running in a windows service as there will be no way for it to respond. When you enter yes to this prompt a file called known_hosts that lets ssh know that this host is ok:

image

This file is created in the .ssh folder under your user profile (Usually C:\Users\<Username>) where ssh can refer back to it (And not prompt you again). The .ssh folder is also where your public and private keys (id_rsa & id_rsa.pub) are stored for writing to a git repository.

Now the nice thing is you can run a git command like clone on you local machine, answer yes to the above prompt and then copy the generated know_hosts file from your local machine to your build server so that it's not prompting during the build process. You can also copy over your public/private keys if your build process needs to write to the repository for some reason.

There are two possible locations where you will need to place these files on your build server in order for ssh to pick them up. One is the folder under the user profile "C:\Users\<Username>\.ssh" (That we already mentioned). Your build server service(s) should be running under a user account (Not as LocalSystem, tisk tisk!) and the username would be that of the account the service is running under. If your running under LocalSystem I would assume that you would have to put the files under "C:\Users\Default\.ssh" but that's just a guess as I've not actually tried it. The other location, if you used the msysgit installer, is in the git binary folder under program files ; "%PROGRAM_FILES%\Git\.ssh". Interestingly, in the process of setting up git to work with Go I found that when the build server ran ssh it looked under "%PROGRAM_FILES%\Git\.ssh" and when the build agent ran it looked under "C:\Users\<Username>\.ssh". I have no clue why it would look in different spots but that's what it was doing so beware. If all else fails you can fire up procmon and see where its looking (Which is what I did).

Once these files are in place you may need to restart the build server services in order for it to pick up the new files.