配置 Git 以使用 Plink

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2985074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 08:31:40  来源:igfitidea点击:

Configure Git to use Plink

gitmsysgitplink

提问by Terminal58

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 配置为使用 Plink。它以前对我有用过很多次。现在,出于某种原因,我无法使用此选项(已禁用):

Git Setup Plink option screenshot

Git 设置 Plink 选项截图

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

我尝试卸载并重新安装 Git 一百次。没有。我无法启用此选项。

回答by andypaxo

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:

我刚刚遇到了这个问题(使用较新版本的 Git,1.7.9)。我使用了 VonC 的答案,但只需要几个步骤:

  1. Set the environment variable GIT_SSHto the location of plink.exe
  2. Run pagent.exeand load your private key
  1. 将环境变量设置GIT_SSHplink.exe
  2. 运行pagent.exe并加载您的私钥

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

在 64 位 Windows 上,plink 的默认位置是C:\Program Files (x86)\GitExtensions\PuTTY\plink.exe路径中的空格似乎不再是问题。

回答by jhcaiced

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.

  • msysgit 安装程序没有显示允许在 openssh 客户端和 Tortoise (plink) 之间进行选择的屏幕

  • 解决方案是安装 Putty(或我猜是 Tortoise Plink),创建并保存至少一个会话,只是安装 Putty 不起作用,必须创建会话,安装程序对此进行了一些奇怪的检查。

  • 当您再次运行 Git 安装程序时,屏幕应该会出现。

enter image description here

在此处输入图片说明

回答by VonC

This looks like issue 368

这看起来像问题 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.

当我更新安装程序时,从未询问我是否要使用 PLink。
现在 Git 继续寻找 OpenSSH 密钥。Git 找不到我的腻子键。

我试过加载我的腻子私钥并重新安装 Git。无论我做什么,我都无法让 Git 使用我的腻子 plink 数据和私钥。

This has a workaround (issue 367)

这有一个解决方法(问题 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.

1) 确保 plink 在PATH
2) 保存一个腻子会话的设置(不管是哪一个)

并在安装 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\puttyto c:\putty.
  3. I set the environment variable GIT_SSHto the new path. c:\putty\plink.exe.

With these changes GIT is now functioning properly.

我终于能够让 GIT 与 Plink 一起工作。

一条评论:
我确实在安装 GIT 之前启动了 Plink 会话。即使 Plink 会话正在运行,我也永远无法让安装程序识别 PLink 正在运行。

我的工作:

  1. 我终于安装了 GIT 1.6.5.1。
  2. 更改了 Plink 路径以删除空格。我将目录从:更改 c:\program files\puttyc:\putty.
  3. 将环境变量GIT_SSH设置为新路径。c:\putty\plink.exe.

通过这些更改,GIT 现在可以正常运行。



Janusz Skoniecznyadds in the comments:

Janusz Skonieczny在评论中补充道:

To setup this quickly run PowerShell as admin:

要设置它,请以管理员身份快速运行 PowerShell:

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


Update March 2017, for Git 2.13 (Q2 2017)

2017 年 3 月更新,适用于 Git 2.13(2017 年第二季度)

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

Git 现在会自动检测您需要的 ssh(openssh 或 plink),但您可以使用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)

请参阅提交 dd33e07(2017 年2 月 1 日)和Segev Finer ( )提交的 e9d9a8a(2017 年 1 月 2 日。 请参阅Johannes Schindelin ( )提交的 e2824e4(2017 年 2 月 1 日)。 请参阅Junio C Hamano() 的commit 6a4f3a9(2017 年 1 月 26 日(由Junio C Hamano合并-- --提交 be6ab59,2017 年 2 月 27 日)segevfiner
dscho
gitster
gitster

ssh.variant:

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

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

根据环境变量GIT_SSHor 的值GIT_SSH_COMMAND或配置设置core.sshCommand,Git 自动检测是否调整其命令行参数以用于plinktortoiseplink,而不是默认值 (OpenSSH)。

ssh.variant可以设置配置变量来覆盖此自动检测;
有效值为sshplinkputtytortoiseplink
任何其他值都将被视为正常的 ssh。
可以通过环境变量覆盖此设置GIT_SSH_VARIANT

回答by user3042599

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

如果你使用 TortoiseGit,你可以永久配置它的 plink。当然在你的机器上使用正确的路径。

setx GIT_SSH "C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe"