首页 > 解决方案 > 通过共享互联网从远程服务器连接到 Github

问题描述

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

ssh -T git@github.com

我收到此错误:

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

有人可以帮忙吗?

标签: gitssh

解决方案


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

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

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

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

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

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

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

编辑您的 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节用于所有连接)。


推荐阅读