通过共享互联网从远程服务器连接到 Github

时间:2021-06-15 11:12:27

标签: git ssh

我已使用 this documentation 通过离线远程服务器共享我的本地互联网。一切正常,远程服务器现在可以上网了。 apt、curl 等大多数东西都在工作。但是当我想通过以下命令连接到 github 时:

ssh -T git@github.com

我收到此错误:

ssh: Could not resolve hostname github.com: Temporary failure in name resolution

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:2)

如果 curl 可以正常工作,但不能 SSH,请尝试至少使用 HTTPS 进行克隆:

git clone https://github.com/<me>/<myRepo>

如果需要,您可能需要定义一个代理 (HTTP_PROXY/HTTPS_PROXY),并将 NO_PROXY 设置为“127.0.0.1,localhost,.mycompany.com”。

仍然使用 ssh 意味着,正如 OP 所建议的:

  • git config https.proxy http://a/proxy
  • 使用 bryanpkc/corkscrew,这是一种通过 HTTP 代理建立 SSH 隧道的工具

(假设这不违反当地 IT 政策)

例如参见 Using Corkscrew to tunnel SSH over HTTP 中的“Vincent Danen”:

<块引用>

编辑您的 SSH 配置文件 ~/.ssh/config,并添加:

Host somehost
   Hostname somehost.example.com #ssh.github.com for Github
   Port 443 #443 for Github
   ProxyCommand /user/bin/corkscrew proxy.example.com 3129 %h %p

OpenSSH 透明地将 %h 转换为要连接的主机名 (somehost.example.com) 和要连接的端口(默认为 22)。

此处的 ProxyCommand 行告诉 OpenSSH 启动 Corkscrew 程序以与终端 SSH 服务器建立实际连接。 > 您可以为您可能需要连接的所有主机创建多个条目,或者在 * 行中使用简单的正则表达式或全局星号 (Host)(* 会告诉OpenSSH 以将此 Host 节用于所有连接)。