GitExtensions + Putty via SSH on custom port

醉酒当歌 提交于 2019-12-01 17:39:18

Got it figured out.

Here's what got me down the wrong path:

  • Do not create any sessions in Putty as outlined here
  • Do not use any host aliases you might have defined in ~/.ssh/config

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

For me, I kept getting an error that host name did not exist. After trying a bunch of suggestions on this and other threads, I checked my remote URL and that was the culprit. If you are using putty, make sure it starts with git@github.com not https://github

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!