How to set up SSH auth with Windows/git/tortoisegit/putty/Synology

22,584

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:

PuTTY Key Generator

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.

Share:
22,584

Related videos on Youtube

me--
Author by

me--

Updated on September 18, 2022

Comments

  • me--
    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
      Admin over 10 years
      Good 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
      Admin over 10 years
      Have you tried to SSH directly into your git user with the public key? If so, did your git user authenticate you?
    • Admin
      Admin over 8 years
      So, 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--
    me-- over 10 years
    Just 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--
    me-- over 10 years
    I also just tried a key without a password protecting it - same issue.
  • me--
    me-- over 10 years
    Thanks. Tried. Still no luck. plink just says "Interactive git shell is not enabled". I think I give up.
  • Nick Grealy
    Nick Grealy almost 9 years
    +1 GIT_SSH & SVN_SSH did it for me!