在git-bash中ssh到github(ssh key有passphrase), 路径分隔符导致命名无效,如何解决?

在git for windows 的 git-bash 中使用 ssh 协议,对github某个库进行操作。ssh key 带有 passphrase。

同时,在 git-bash 中设定了 socks5 代理。

目录 c:\users\[myusrname]\.ssh\ 下就有3个文件:
id_rsa, id_rsa.pub, config(代理配置)

config 文件的内容是:

Host github.com
User git
ProxyCommand connect -S 127.0.0.1:8088 %h %p

代理工作正常。

为了测试,先执行 ssh -T git@github.com,得到错误提示:

$ ssh -T git@github.com
'D:\GreenSoft\PortableGit\mingw64\libexec\git-core\git-gui--askpass' is not recognized as an internal or external command, operable program or batch file.
FATAL: Cannot get password for user: rasan
ssh_exchange_identification: Connection closed by remote host

而路径D:\GreenSoft\PortableGit\mingw64\libexec\git-core 已经被加入到 windows 的系统环境变量中。
在 git-bash 中输入 env|grep git-core 可以看到 git-bash 的 $PATH 环境变量也有该路径存在。

$ env|grep git-core
SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass
PATH=/c/Users/rasan/bin:[...]:/mingw64/libexec/git-core

如果进入该目录,单独执行 git-gui--askpass,程序是正常执行的,会弹出一个窗口询问 passphrase 。

最后,我发现问题在于斜杠的方向或样式不对。

D:\GreenSoft\PortableGit\mingw64\libexec\git-core\git-gui--askpass is wrong command.

but

D://GreenSoft/PortableGit\mingw64\libexec\git-core\git-gui--askpass
or
D://GreenSoft//PortableGit//mingw64//libexec//git-core//git-gui--askpass are correct command.

斜杠的方向和风格在哪里配置呢?

阅读 2.8k
1 个回答

试试下面这几种组合:

D:/GreenSoft/PortableGit/mingw64/libexec/git-core/git-gui--askpass
/D/GreenSoft/PortableGit/mingw64/libexec/git-core/git-gui--askpass
D:\\GreenSoft\\PortableGit\\mingw64\\libexec\\git-core\\git-gui--askpass

这个不是完整路径,
PATH=/c/Users/rasan/bin:[...]:/mingw64/libexec/git-core
试试加上
PATH=/c/Users/rasan/bin:[...]:/D/GreenSoft/PortableGit/mingw64/libexec/git-core

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题