【发布时间】:2020-11-09 04:10:33
【问题描述】:
我有 2 个要与 Github 一起使用的帐户,我正在尝试通过遵循 tutorial 将 github 设置为通过 ~/.ssh/config 处理多个帐户。我创建了 2 个 ssh 密钥(例如 rsa_1 和 rsa_2)并像这样设置 ~/.ssh/config 文件:
Host github.com
HostName github.com
User username1
IdentityFile ~/.ssh/id_rsa_1
IdentitiesOnly yes
Host work.github.com
HostName github.com
User username2
IdentityFile ~/.ssh/id_rsa_2
IdentitiesOnly yes
然后,我在要与另一个帐户一起使用的 repo 上设置远程 url
git remote set-url origin work.github.com:<shared_gitrepo_name>/project.git
但是当我 git push origin 时,它总是超时
ssh: connect to host work.github.com port 22: Operation timed out
fatal: Could not read from remote repository.
这让我觉得配置文件没有被引用。我不确定我做错了什么。任何帮助将不胜感激!
【问题讨论】:
-
你能联系到
ssh github.com吗? -
可以,回复如下:ssh -T git@github.com 你已经成功认证,但是GitHub不提供shell访问。
-
那么它在没有 sudo 的情况下是否有效(正如我在讨论中提到的那样)?