我在Windows上使用Portable Git x64。我以Git Bash的想法做所有事情。我需要SSH到只能通过HTTP代理访问的服务器。服务器的验证通过pubkey进行,代理的验证通过密码进行,用户名不同。我的~/.ssh/config
:
Host server
Hostname server_hostname
User server_username
IdentityFile ~/.ssh/id_rsa
ProxyCommand /c/PortableGit/mingw64/bin/connect.exe -H proxy_username@proxy_ip:12345 %h %p
当ssh尝试弹出需要输入HTTP代理密码的窗口时,问题开始,从ssh -vvv server
登录:
$ ssh -vvv server
OpenSSH_7.9p1, OpenSSL 1.1.1a 20 Nov 2018
debug1: Reading configuration data /c/Users/username/.ssh/config
debug1: /c/Users/username/.ssh/config line 1: Applying options for server
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Executing proxy command: exec /c/PortableGit/mingw64/bin/connect.exe -H proxy_username@proxy_ip:12345 server_hostname 22
debug1: identity file /c/Users/username/.ssh/id_rsa type 0
debug1: identity file /c/Users/username/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
'C:\PortableGit\mingw64\libexec\git-core\git-gui--askpass' is not recognized as an internal or external command,
operable program or batch file.
FATAL: Cannot decide password for proxy authentication.ssh_exchange_identification: Connection closed by remote host
git-gui--askpass
在那儿,但是由于某种原因它没有被ssh接收。运行file 'C:\PortableGit\mingw64\libexec\git-core\git-gui--askpass'
给出:
$ file 'C:\PortableGit\mingw64\libexec\git-core\git-gui--askpass'
C:\PortableGit\mingw64\libexec\git-core\git-gui--askpass: POSIX shell script, ASCII text executable
git-gui--askpass
的内容与https://github.com/git/git/blob/3bab5d56259722843359702bc27111475437ad2a/git-gui/git-gui--askpass相同
我尝试通过命令行运行此脚本,它工作正常:
而且,我尝试将另一个程序指定为SSH_ASKPASS=/mingw64/libexec/git-core/git-askpass.exe
(我认为这是一件愚蠢的事情)。这也不起作用:
...
fatal: failed to acquire credentials.
我试图在~/.ssh/config
中提供密码为:
ProxyCommand /c/PortableGit/mingw64/bin/connect.exe -H proxy_username:proxy_password@proxy_ip:12345 %h %p
^^^^^^^^^^^^^^^
但是ssh会忽略它。
[此外,我尝试通过MobaXterm连接,并且可以正常工作-我被要求输入代理密码,输入密码后就可以连接了。另外,在MobaXterm中连接后,由于代理一段时间不要求输入密码,因此我可以在命令行中连接。但是出于另一个原因,我无法使用MobaXterm。
关于如何使其运作的任何想法?
尝试将密码保存在~/.ssh/config
文件中并添加
unset SSH_ASKPASS
至您的.bashprofile