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

7

3

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.

me--

Posted 2013-12-10T06:48:04.547

Reputation: 235

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) – Pavel P – 2016-03-27T00:09:09.903

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. – jcollum – 2013-12-13T00:57:58.247

1Have you tried to SSH directly into your git user with the public key? If so, did your git user authenticate you? – Mark Lopez – 2013-12-14T20:46:32.663

Answers

4

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

portunknown

Posted 2013-12-10T06:48:04.547

Reputation: 41

+1 GIT_SSH & SVN_SSH did it for me! – Nick Grealy – 2015-08-06T07:56:53.047

Thanks. Tried. Still no luck. plink just says "Interactive git shell is not enabled". I think I give up. – me-- – 2013-12-27T01:14:20.133

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.

heavyd

Posted 2013-12-10T06:48:04.547

Reputation: 54 755

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-- – 2013-12-17T00:18:37.313

I also just tried a key without a password protecting it - same issue. – me-- – 2013-12-17T00:27:04.210

0

Adding ssh key in OpenSSH format generated from Putty to your linux account and testing to see if you can log into Github or another linux server

  1. Copy the id_rsa and id_rsa.pub to ~/.ssh folder. Change the permissions of the id_rsa file to 400/600 using chmod 600 ~/.ssh/id_rsa https://stackoverflow.com/a/9270753/4752883

  2. Check if ssh-agent is running using eval $(ssh-agent -s) and start/restartssh-agent` (https://stackoverflow.com/a/17848593/4752883 )

  3. Add ssh private key to ssh-agent: ssh-add ~/id_rsa (https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#adding-your-ssh-key-to-the-ssh-agent)

  4. Verify that public key is attached to your account (https://help.github.com/articles/error-permission-denied-publickey/): ssh-add -l -E md5 . Output should be something like 2048 MD5:de:5d… /home/username/.ssh/id_rsa (RSA)

  5. Verify that you can use ssh to log into github or other server( https://help.github.com/articles/testing-your-ssh-connection/) : ssh -T git@github.com. Output should read Hi username! You've successfully authenticated, but GitHub does not provide shell access.

  6. If it shows an error such as key_load_public: invalid format, it means that you are using the Puttygen public key format. To change to OpenSSH version of public key follow the steps: (https://stackoverflow.com/a/44391850/4752883 )

alpha_989

Posted 2013-12-10T06:48:04.547

Reputation: 623