Configure Git to use Plink
Asked Answered
P

6

52

I'm trying to configure Git to use Plink. It worked for me many times before. Now, for some reason, this option isn't available to me (it is disabled):

Git Setup Plink option screenshot

I tried uninstalling and reinstalling Git a hundred times. Nothing. I can't get to this option enabled.

Peria answered 6/6, 2010 at 17:14 Comment(4)
Are you sure that the environment variable is being set correctly for the process? You can install Process Explorer and use it to examine an already running program.Dovekie
I'm not getting the option to set the variablePeria
What did that screenshot show? Could someone either take a new one or describe it in words?Mertens
It's been over two years since I asked this but I think the image was identical to the one jhcaiced posted. I was just showing what my install didn't show me.Peria
Z
51

This is an old question, and I just have the same problem, just to be sure I will write down the solution that worked for me.

  • The msysgit installer didn't show the screen that allows to select between the openssh client and the Tortoise (plink)

  • The solution is to install Putty (or Tortoise Plink I guess), create and save at least one session, just installing Putty didn't work, the session must be created, the installer does some weird check about that.

  • When you run the Git installer again, the screen should appear.

enter image description here

Zygosis answered 8/10, 2011 at 13:38 Comment(3)
I needed to have Pagent running.Dumfries
It was the second point that got me that step in the installer, thanks!Endurable
for me, running this (for x64 putty) worked on Win Server 2016 set GIT_SSH=C:\Program Files\PuTTY\plink.exeWeariful
T
67

I just had this problem (with a newer version of Git, 1.7.9). I used the answer from VonC, but only a couple of steps were needed:

  1. Set the environment variable GIT_SSH to the location of plink.exe
  2. Run pageant.exe and load your private key

On 64 bit Windows, the default location for plink is C:\Program Files (x86)\GitExtensions\PuTTY\plink.exe The spaces in the path no longer seem to be a problem.

Teleost answered 27/4, 2012 at 15:57 Comment(4)
Worked fine and (assuming you know where to set environment vars) is much easier than reinstalling.Roodepoortmaraisburg
Spaces in the path is still a problem. A workaround is to use a short file name which doesn't contains spaces. One can get a short file name using following command: cmd /c for %A in ("c:\Path\ to\ file") do @echo %~sA.Annapolis
@Annapolis I solved the spaces issue by creating a link. c:\apps is a pre-exisiting directory on my PC, you can replace this by any directory you like. Execute following as administrator mklink /j /d c:\apps\putty "c:\Program Files (x86)\PuTTY" Execute regular user set GIT_SSH=c:\apps\putty\plink.exe To test ssh authentication I used c:\apps\putty\plink -v [email protected]Opal
I had to additionally manually acknowledge/add the server's key into cache by typing plink github.com hitting y and then Ctrl-C. Clone worked afterwardsAreaway
Z
51

This is an old question, and I just have the same problem, just to be sure I will write down the solution that worked for me.

  • The msysgit installer didn't show the screen that allows to select between the openssh client and the Tortoise (plink)

  • The solution is to install Putty (or Tortoise Plink I guess), create and save at least one session, just installing Putty didn't work, the session must be created, the installer does some weird check about that.

  • When you run the Git installer again, the screen should appear.

enter image description here

Zygosis answered 8/10, 2011 at 13:38 Comment(3)
I needed to have Pagent running.Dumfries
It was the second point that got me that step in the installer, thanks!Endurable
for me, running this (for x64 putty) worked on Win Server 2016 set GIT_SSH=C:\Program Files\PuTTY\plink.exeWeariful
M
22

This looks like issue 368

When I updated the install never asked if I wanted to use PLink.
Now Git continues to look for an OpenSSH key. Git could not find my putty key.

I have tried loading my putty private key and reinstalling Git. No matter what I do I can't get Git to use my putty plink data and private key.

This has a workaround (issue 367)

1) making sure that plink is in PATH
2) Saving settings for one putty session (doesn't matter which one)

and by doing those before installing git.


Even with that process, it is not easy:

I was finally able to get GIT to work with Plink.

One comment:
I did start a Plink session before installing GIT. Even with a Plink session running I never able to get the installer to recognize PLink was running.

My work around:

  1. I finally just installed GIT 1.6.5.1.
  2. I changed the Plink path to removes spaces. I changed the directory from: c:\program files\putty to c:\putty.
  3. I set the environment variable GIT_SSH to the new path. c:\putty\plink.exe.

With these changes GIT is now functioning properly.


Janusz Skonieczny adds in the comments:

To setup this quickly run PowerShell as admin:

[Environment]::SetEnvironmentVariable("GIT_SSH", "D:\your_path_here\plink.exe", "User")

Update March 2017, for Git 2.13 (Q2 2017)

Git now auto-detects the ssh you need (openssh or plink), but you can force that detection with ss.variant.

See commit dd33e07 (01 Feb 2017), and commit e9d9a8a (02 Jan 2017) by Segev Finer (segevfiner).
See commit e2824e4 (01 Feb 2017) by Johannes Schindelin (dscho).
See commit 6a4f3a9 (26 Jan 2017) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit be6ab59, 27 Feb 2017)

ssh.variant:

Depending on the value of the environment variables GIT_SSH or GIT_SSH_COMMAND, or the config setting core.sshCommand, Git auto-detects whether to adjust its command-line parameters for use with plink or tortoiseplink, as opposed to the default (OpenSSH).

The config variable ssh.variant can be set to override this auto-detection;
valid values are ssh, plink, putty or tortoiseplink.
Any other value will be treated as normal ssh.
This setting can be overridden via the environment variable GIT_SSH_VARIANT.

Metropolitan answered 6/6, 2010 at 17:46 Comment(5)
The highlights: avoid spaces in path to plink.exe; point GIT_SSH at plink.Mertens
Why isn’t plink in your PATH? GIT_SSH=plink works fine for me :-pAntipater
@Antipater because I had several plink (one with putty, one with GoW (github.com/bmatzelle/gow/wiki), and I wanted to be sure to reference the one I wanted.Metropolitan
To setup this quickly run PowerShell as admin: [Environment]::SetEnvironmentVariable("GIT_SSH", "D:\your_path_here\plink.exe", "User")Tranquil
@JanuszSkonieczny Good point. I have included your comment in the answer for more visibility.Metropolitan
C
2

If you are using TortoiseGit, you can permanently configure its plink. Of course use correct path on your machine.

setx GIT_SSH "C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe"
Circuit answered 28/11, 2017 at 20:18 Comment(0)
P
1

I used for many years the solution with GIT_SSH environment variable, but sometime this year it stopped working (after update of git bash or putty toolkit). I've found current working soultion. First, your pageant must be running. Second you must start ssh agent, but the windows one:

eval `ssh-pageant`

It is windows equivalent of what unix users know:

eval `ssh-agent`

To add keys you can use ssh-add or Pagenant UI window.

Pornocracy answered 25/11, 2020 at 11:14 Comment(0)
S
0

This is what I did to fix it on my machine (Windows 10 Pro x64) in January 2023.

1 & 2) Configured TortoiseGit (in its settings... Network >> SSH >> SSH client) and Git (the GIT_SSH environment variable) to both use     C:\Program Files\PuTTY\plink.exe without quotation marks.

3 & 4) Set up both Pageant and ssh-add agent to auto-start (I used the ssh agent script from https://docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases and use my private key.

Stockton answered 10/1, 2023 at 0:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.