【发布时间】:2017-08-20 00:08:58
【问题描述】:
我已经用我的 github 帐户注册了一个 ssh 密钥。 钥匙在
~/.ssh/id_rsa_github_snail
~/.ssh/id_rsa_github_snail.pub
我有一个 repo,其中远程 url 配置为使用 ssh:
$ git remote -v
origin git@github.com:danielsank/pong.git (fetch)
origin git@github.com:danielsank/pong.git (push)
但是,当我尝试从公司计算机推送时,我收到以下错误消息
danielsank@snail:~/src/pong$ git push
ssh: connect to host github.com.<company>.<name>.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
请注意,由于某种原因,ssh 尝试连接到 github.com.<company>.<name>.com 而不是 github.com。
我在/etc/resolve.conf中发现了以下可疑位:
# It is common within <company> to lookup hostnames with a dot in it like for an
# example '<machine>.<site>'. We set 'options ndots:2' so that such hostnames
# get tried first with the <company> search domains appended. Without this such
# queries might be tried first against an external DNS resolver.
options ndots:2
我可以 ping github.com。
我尝试将网址设置为git@github.com.:danielsank/pong.git。
之后,当我尝试推送时,我被要求接受来自 github 的主机指纹,但随后出现不同的错误:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我想这是由于 repo 名称中的额外点而发生的。
是否有解决此配置的好方法? 如果不附加公司名称,决议不会再试一次,我有点惊讶......
【问题讨论】:
-
您的
/etc/resolv.conf中有什么内容?你可以ping github.com吗?试试ping github.com.(注意尾随点)。尝试将origin更改为git@github.com.:danielsank/pong.git(再次注意添加的点)。 -
https 版本好用吗?
https://github.com/danielsank/pong.git -
@Trolleymusic 目前没有,因为我在我的 github 帐户上启用了 2-factor(这就是整个事情的开始)。