具有两个 ssh key 的 gitlab 未连接(配置已更新)

标签 git macos ssh gitlab

我的 Mac 上有一个 gitlab 帐户,其中包含我的工作帐户所需的 ssh key 。我正在尝试为我所有的个人项目设置 gitlab。我已经在 gitlab 上创建了个人帐户并创建了 ssh key 。

我已经编辑了 ~/.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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92f5fbe6d2f5fbe6fef3f0bcf1fdff" rel="noreferrer noopener nofollow">[email protected]</a>

我明白了

Welcome to GitLab, *my work account welcome*!

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

最佳答案

检查您的 .git/config 表现如何看起来像。我猜你没有urlmarkbreadcreative. 开始和markgameforeverything.前缀。

要使您的设置正常工作,您需要修改存储库中的行

url = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7a0aeb387a0aeb3aba6a5e9a4a8aa" rel="noreferrer noopener nofollow">[email protected]</a>:whatever.git

url = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92f5fbe6d2fff3e0f9f0e0f7f3f6f1e0f7f3e6fbe4f7bcf5fbe6fef3f0bcf1fdff" rel="noreferrer noopener nofollow">[email protected]</a>:whatever.git
url = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e5828c91a58884978e82848880838a97809380979c918d8c8b82cb828c91898487cb868a88" rel="noreferrer noopener nofollow">[email protected]</a>:whatever.git

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

ssh -T <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9cfbf5e8dcf1fdeef7feeef9fdf8ffeef9fde8f5eaf9b2fbf5e8f0fdfeb2fff3f1" rel="noreferrer noopener nofollow">[email protected]</a>
ssh -T <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a1d130e3a171b08111d1b171f1c15081f0c1f08030e1213141d541d130e161b1854191517" rel="noreferrer noopener nofollow">[email protected]</a>

(应该返回不同的结果)。如果没有,请发布此类命令的详细日志 ( ssh -vvvT <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dbbcb2af9bb6baa9b0bcbab6bebdb4a9beadbea9a2afb3b2b5bcf5bcb2afb7bab9f5b8b4b6" rel="noreferrer noopener nofollow">[email protected]</a> )。

关于具有两个 ssh key 的 gitlab 未连接(配置已更新),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35297959/

相关文章:

linux - 用于验证 ssh 公钥的 bash 脚本未被请求

git - SSL证书问题: self signed certificate in certificate chain

git - 将非 git 文件夹与 git 文件夹 merge

swift - 由于 MacOSX10.11.sdk 的奇怪错误,根本无法构建任何 Swift 项目

ios - 在一个 MacOS 帐户上使用多个 Apple 开发者帐户?

MySQL 连接只能通过命令行工作

linux - 无法通过 SSH 保留最新的 5 个文件夹并删除较旧的文件夹

bash - SSH while read line 循环而不使用远程命令

git - .gitignore 文件仍显示在未跟踪列表中

git - 列出 Git remote 中所有活跃的分支