【问题标题】:Git through SSH proxy works in Windows but not in Ubuntu通过 SSH 代理的 Git 在 Windows 中有效,但在 Ubuntu 中无效
【发布时间】:2018-06-23 18:23:51
【问题描述】:

常见场景:我正在尝试访问我们公司网络中的 git 服务器。我无法直接访问它,但我可以通过 ssh 连接到公司网络内的我的 PC,然后从那里连接到 git 服务器。

我已经设置了以下 ssh 配置:

Host company.pc
    HostName public.company.pc
    User user
    Port 1234
    IdentityFile ~/.ssh/id_rsa

Host gitserver
    HostName private.company.gitsrv
    User git
    IdentityFile ~/.ssh/gitserver
    IdentitiesOnly yes
    ProxyCommand ssh company.pc exec nc %h %p

然后我发出命令git clone git@gitserver:path/to/git

在 Windows 上,这没有问题:首先提示我输入 company.pc 的密码,然后提示输入 ~/.ssh/gitserver 的密码和存储库克隆。

然而,在 Ubuntu 上,当我输入前两个密码后,系统再次提示我输入 git@gitserver。我的猜测是,在 Ubuntu 中,~/.ssh/gitserver 私钥不用于向 gitserver 进行身份验证。

【问题讨论】:

  • 试试ProxyCommand ssh -W %h:%p company.pc。这不是关于密码/密钥的答案,只是对于较新版本的 OpenSSH 更好的ProxyCommand
  • @phd 新命令的优势是什么?有什么不同?
  • 内置OpenSSH,无需运行外部程序nc

标签: git ubuntu ssh


【解决方案1】:

想通了。不知何故,我设法将错误的 gitserver 密钥下载到了 Ubuntu 机器上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-06
    • 2015-07-16
    • 1970-01-01
    • 2012-03-26
    • 1970-01-01
    • 2020-05-14
    • 1970-01-01
    • 2014-10-23
    相关资源
    最近更新 更多