【问题标题】:Windows SSH ProxyCommand /usr/bin/bash: line 0: exec: nc: not found on git bashWindows SSH ProxyCommand /usr/bin/bash: line 0: exec: nc: not found on git bash
【发布时间】:2022-01-06 07:02:34
【问题描述】:

我正在尝试通过 Windows Git Bash 上的中间跳转主机通过 SSH 连接到服务器,但出现以下错误。

/usr/bin/bash:第 0 行:exec:nc:未找到

$ ssh -vnNT -L 2555:destination-server.com ubuntu@x.amazonaws.com -o "ProxyCommand=nc -X 5 -x proxy.abc.com:4850 %h %p"

OpenSSH_8.8p1, OpenSSL 1.1.1l  24 Aug 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Executing proxy command: exec nc -X 5 -x proxy.abc.com:4850 x.amazonaws.com 22
debug1: Local version string SSH-2.0-OpenSSH_8.8
/usr/bin/bash: line 0: exec: nc: not found *********************************** => ERROR LINE
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535

我该如何解决这个错误?

【问题讨论】:

    标签: windows ssh proxy netcat jumphost


    【解决方案1】:

    原因是 Git Bash for Windows 没有 nc (netcat) 命令。

    作为一种解决方法,请替换:

    nc -X 5 -x proxy.abc.com:4850 %h %p
    

    connect -S proxy.abc.com:4850 %h %p
    

    所以最后的命令是:

    ssh -vnNT -L 2555:destination-server.com ubuntu@x.amazonaws.com -o "ProxyCommand=connect -S proxy.abc.com:4850 %h %p"
    

    即使您在 ssh 配置文件中使用 nc,也可以将 nc -X 5 -x 替换为 connect -S,它应该可以工作。

    例子:

    替换

    【讨论】:

      猜你喜欢
      • 2013-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-05
      • 2019-06-27
      • 1970-01-01
      相关资源
      最近更新 更多