【问题标题】:SSH via HTTP proxy with password on Windows with mingw64使用 mingw64 在 Windows 上通过带有密码的 HTTP 代理进行 SSH
【发布时间】:2020-03-27 14:11:23
【问题描述】:

我在 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。

关于如何使它工作的任何想法?

【问题讨论】:

  • 为什么在log Executing proxy command里说被忽略?
  • “在日志中执行代理命令”是什么意思?如果我在 .ssh/config 中指定代理的密码,它会被 ssh 忽略,在日志中没有关于密码的任何内容,ssh 尝试弹出密码窗口并失败。

标签: ssh proxy mingw http-proxy


【解决方案1】:

实用程序 connect.exe 与 HTTP_PROXY_USER 和 HTTP_PROXY_PASSWORD 环境变量一起使用。解决方案在source code

【讨论】:

  • 非常感谢,成功了!此外,非常感谢对源代码的引用,我能够确定我遇到的另一个问题!
【解决方案2】:

尝试将您的密码保存在您的 ~/.ssh/config 文件中并添加

unset SSH_ASKPASS

到你的 .bashprofile

【讨论】:

  • 今天尝试了您的建议。在这种情况下基本上什么都没有发生,它在需要请求代理通行证的那一刻挂断,我假设忽略了来自配置的密码。我最终使用了腻子,有一个选项可以为代理指定密码..
猜你喜欢
  • 2017-06-18
  • 2013-01-19
  • 1970-01-01
  • 2015-09-11
  • 2012-02-23
  • 2012-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多