How to set up SSH auth with Windows/git/tortoisegit/putty/Synology
Solution 1
Make sure you have followed heavyd directions on the ssh keys
Windows Git AND TortoiseGit require 2 environment variables set in Windows.
GIT_SSH=C:\Program Files\TortoiseGIT\bin\TortoiseGitPlink.exe
SVN_SSH=C:\Program Files\TortoiseGIT\bin\TortoiseGitPlink.exe
(replace with your paths if different)
You also need to make sure the PLINK_PROTOCOL is not being overridden. Otherwise, PLINK_PROTOCOL=ssh
After making these changes, verify access with the following:
Open a Dos Command window issue the command plink git@your git depot server name
If a list of Git repositories is returned, you are communicating with Git.
If an error is returned, you may need to edit your .ssh/config and/or etc/hosts windows files
Solution 2
You don't want to use the public key that is saved using the "Save public key" button. From within PuTTY Key Generator UI you should copy the text in the top box into your authorized_keys
file:
It should be copied exactly and should end up being a single line in your authorized_keys
file.
Also, are you using ssh://root@server/foo/bar
to clone your repo? If not, you need to make sure you're adding your public key to the authorized_keys
file for the correct user.
Related videos on Youtube
me--
Updated on September 18, 2022Comments
-
me-- almost 2 years
I'm hopelessly confused. I am trying to stop tortoisegit from prompting me for a password every time I pull/push (I don't mind once for each time I log on to Windows, but thereafter I want it to be automatic).
My git server is running on my Synology NAS via the official Git Server package. I clone via ssh://user@server/foo/bar.
Here's what I have done/tried:
- created myself a public and private key pair via Puttygen.
- started Putty Authentication Agent (pageant) and added my private key to it.
- created an authorized_keys file on the server at /root/.ssh/. I've tried with just the Base64-encoded portion of the public key file, and also with the
---- BEGIN SSH2 PUBLIC KEY ----
header and corresponding footer. - set tortoisegit up to use TortoiseGitPLink.exe as the SSH client (the default, I believe). I've also tried pageant.exe, but that results in an error: "Couldn't load this key (unable to open file)"
I am still prompted for a password, and the Putty Agent does not appear to be involved in the process in any way (no keys even after authenticating). Any advice would be much appreciated.
-
Admin over 10 yearsGood luck man, I went down this road a while back and found it to be a pain. In the end I decided to dev on an Ubuntu VM. This wasn't the only factor tho.
-
Admin over 10 yearsHave you tried to SSH directly into your git user with the public key? If so, did your git user authenticate you?
-
Admin over 8 yearsSo, did you figure out what was wrong? Perhaps you shouldn't have used
root
user for git. Did you also have a putty session saved, seems like TortoiseGitPlink.exe needs it (and saved putty session needs a key in pageant)
-
me-- over 10 yearsJust tried both your suggestions but am still prompted for a password. The reason I originally put the authorized_keys file under root because it just seems wrong that any user can grant themselves access to git just by creating said file in their home directory...
-
me-- over 10 yearsI also just tried a key without a password protecting it - same issue.
-
me-- over 10 yearsThanks. Tried. Still no luck. plink just says "Interactive git shell is not enabled". I think I give up.
-
Nick Grealy almost 9 years+1
GIT_SSH
&SVN_SSH
did it for me!