GitExtensions + Putty通过SSH自定义端口 [英] GitExtensions + Putty via SSH on custom port

查看:1037
本文介绍了GitExtensions + Putty通过SSH自定义端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git仓库,使用类似下面的路径:

  git pull ssh:// username @ host.:1234/path/to/repository.git 

当GitExtensions尝试从repo使用plink,它使这个调用:

  plink -T username@host.com:/path/to/repository.git 

这最终会失败,因为它实际上是ping 22号端口,而不是#1234。



正确的调用将是

  plink -T -P 1234 username @ host.com:/path/to/repository.git 

如果我在其中创建别名hostCom我的〜/ .ssh / config,它似乎工作正常(连接到#1234)如果我只是这样做:

  plink -T username @ hostCom 

但是,只要我将路径添加到git repo中,到#22再次。

我尝试的另一个选择是在腻子中创建一个会话,让我们来看看将它设置为hostPutty,然后设置默认端口等等。底线结束是相同的,尽管如此:无法将路径与git repo结合到自定义端口。



如何将所有零件组合起来使它们工作?



以及OpenSSH如何处理这个问题,但腻子不能? OpenSSH唯一的问题是,每次连接尝试时都会要求我输入私钥的密码(并且我不想在没有密码的情况下创建私钥)。



这是让我失望的道路:





以下是如何运作:


  • 显然要确保GitExtensions设置为使用Putty,而不是OpenSSH

  • 确保plink.exe(可用于GitExtensions或专门与Putty一起安装)位于不含空格的路径中
  • 设置env变量%GIT_SSH%指向plink.exe(它可能指向默认情况下的ssh.exe),请确保在那里没有撇号,因为该值将被按原样使用(这就是为什么您不能使用上述空格)



      c:\> echo%GIT_SSH%
    C:\tools\PuTTY\plink.exe




    $ b
  • 使用完整命令来拉,否在上面的例子中,允许你不指定端口等的主机别名。如果端口丢失,并且只有一个冒号,git会将其视为一个路径分隔符,并将ssh作为端口分隔符(因此它们每个都很糟糕)。



    git克隆ssh://username@host.com:1234 / path / to / repository.git




如果你不这样做,你可能会遇到各种各样的问题,如:

$

$ gb + plink实际上找出正确的东西!

b
$ b


  • 如果%GIT_SSH%指向ssh.exe并使用主机别名代替路径incl。 port




  ssh.exe:hostPutty:path:no与名称
相关的地址致命:远程端意外挂起





  • 在%GIT_SSH%中使用的省略号




  •   error:can not spawnC:\tools\PTTTY\plink.exe:No such file or directory 
    fatal:could not fork



    I have a git repository that I pull using a path similar to this:

    git pull ssh://username@host.com:1234/path/to/repository.git
    

    When GitExtensions then tries to pull from the repo using plink, it makes this call:

    plink -T username@host.com:/path/to/repository.git
    

    This ends up failing because it's actually pinging port #22, and not #1234.

    The right call to make would be

    plink -T -P 1234 username@host.com:/path/to/repository.git
    

    If I create an alias "hostCom" in my ~/.ssh/config, it seems to work correctly (connecting to #1234) if I just do this:

    plink -T username@hostCom
    

    But as soon as I add the path to the git repo too, it goes to #22 again.

    Another option I tried is to create a session in putty, let's call it "hostPutty", and set the default port there etc. The bottom line ends up being the same though: Can't combine path to git repo with custom port.

    How do I combine all the parts to make them work?

    And how come OpenSSH can deal with the problem, but Putty can't? The only problem with OpenSSH is that it keeps asking me for the password for the private key on every connection attempt (and I don't want to create a private key without a password).

    解决方案

    Got it figured out.

    Here's what got me down the wrong path:

    Here's how you get it working:

    • Obviously make sure GitExtensions is set to use Putty, not OpenSSH
    • Make sure plink.exe (the one available with GitExtensions or specifically installed with Putty) is in a path without spaces
    • Set your env variable %GIT_SSH% to point to plink.exe (it might be pointing to ssh.exe by default), make sure there are no apostrophes since the value will be used "as-is" (that's why you can't use spaces as stated above)

      c:\>echo %GIT_SSH%
      C:\tools\PuTTY\plink.exe
    

    • Use the "full" command to pull, no host aliases that would allow you to not specify the port etc., in the example above. If the port is missing, and there's just a colon, git treats it as a path separator, and ssh as port delimiter (so they bite each fairly bad).

      git clone ssh://username@host.com:1234/path/to/repository.git

    If you do that Git + plink actually figure things out right!

    If you don't do it this way, you might run into all kinds of problems like:

    • Had %GIT_SSH% pointed to ssh.exe and used host alias instead of path incl. port

      ssh.exe": hostPutty:path: no address associated with name
      fatal: The remote end hung up unexpectedly
    

    • Used apostrophes in %GIT_SSH%

      error: cannot spawn "C:\tools\PuTTY\plink.exe": No such file or directory
      fatal: unable to fork
    

    这篇关于GitExtensions + Putty通过SSH自定义端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆