SSH 通过 HTTP 代理,密码为 Windows,使用 mingw64
SSH via HTTP proxy with password on Windows with mingw64
我在 Windows 上使用便携式 Git x64。我运行什么都想GitBash。我需要通过 ssh 连接到只能通过 HTTP 代理访问的服务器。服务器的身份验证是通过公钥,代理的身份验证是通过密码,用户名不同。我的 ~/.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 尝试弹出 window 需要输入 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
到您的 .bash 配置文件
实用程序 connect.exe 使用 HTTP_PROXY_USER 和 HTTP_PROXY_PASSWORD 环境变量。在 source code
中找到解决方案
我在 Windows 上使用便携式 Git x64。我运行什么都想GitBash。我需要通过 ssh 连接到只能通过 HTTP 代理访问的服务器。服务器的身份验证是通过公钥,代理的身份验证是通过密码,用户名不同。我的 ~/.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 尝试弹出 window 需要输入 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
到您的 .bash 配置文件
实用程序 connect.exe 使用 HTTP_PROXY_USER 和 HTTP_PROXY_PASSWORD 环境变量。在 source code
中找到解决方案