【问题标题】:gitlab with two ssh keys not connecting (config updated)带有两个 ssh 密钥的 gitlab 未连接(配置已更新)
【发布时间】:2016-02-10 02:15:43
【问题描述】:

我的 Mac 上有一个 gitlab 帐户,上面有我工作帐户所需的 ssh 密钥。我正在尝试为我所有的个人项目设置 gitlab。我在 gitlab 上创建了个人帐户并创建了 ssh 密钥。

我已将 ~/.shh/ 中的配置文件编辑为如下所示

Host markgameforeverything.gitlab.com
    HostName gitlab.com
    User git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/personal.pub

Host markbreadcreative.gitlab.com
    HostName gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa.pub

但是我做不到

git pull

当我收到此错误时

GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists

如果我输入

ssh -T git@gitlab.com

我明白了

Welcome to GitLab, *my work account welcome*!

(错误的帐户) 任何人都可以建议我可能采取的任何进一步步骤或在我的代码中看到错误吗?

【问题讨论】:

    标签: git macos ssh gitlab


    【解决方案1】:

    检查您的.git/config 的外观。我猜你没有以markbreadcreative.markgameforeverything. 开头的url 前缀。

    要使您的设置正常工作,您需要从

    修改您的 repo 中的行
    url = git@gitlab.com:whatever.git
    

    url = git@markbreadcreative.gitlab.com:whatever.git
    url = git@markgameforeverything.gitlab.com:whatever.git
    

    分别取决于您要使用的帐户。您可以使用以下方式检查您的配置:

    ssh -T git@markbreadcreative.gitlab.com
    ssh -T git@markgameforeverything.gitlab.com
    

    (应该返回不同的结果)。如果没有,请发布此类命令的详细日志 (ssh -vvvT git@markgameforeverything.gitlab.com)。

    【讨论】:

    • 对不起,你怎么打开.git/config
    • 如果我做 ssh -T git@markbreadcreative.gitlab.com 我得到你好标记
    • 例如在您最喜欢的文本编辑器中使用打开菜单。
    • 我遇到了完全相同的问题,但我无法检查 ssh -T git@<personal-account>.gitlab.com,因为它说“无法解析主机名”。
    • @aalaap 因为您没有在~/.ssh/config 中正确配置 ssh。
    猜你喜欢
    • 2016-11-10
    • 2020-03-01
    • 2021-01-15
    • 2022-01-21
    • 2020-01-10
    • 2015-06-28
    • 1970-01-01
    • 1970-01-01
    • 2022-09-23
    相关资源
    最近更新 更多