【问题标题】:Git ERROR: Repository not foundGit 错误:找不到存储库
【发布时间】:2018-12-09 23:15:18
【问题描述】:

我一直在阅读其他 Git 存储库未发现错误,但仍在努力解决我遇到的问题。

我正在处理一个本地存储库,将其推送到 Forge 监视的 Remote,并在更新主分支时部署到生产环境。它没有部署我正在推动的更改!我做出了 4 项在网站上尚未实现的贡献。我还尝试通过立即部署按钮从 Forge 中手动部署代码,但这也不起作用。我得到的错误附在下面。

Fri Jun 29 08:30:42 UTC 2018
ERROR: Repository not found.
fatal: Could not read from remote repository.

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

我是 GitHub 项目的贡献者。我已经将我的 SSH 密钥添加到我的 github 帐户以及 Forge 管理区域,这样我就可以 ssh 进入 Forge 服务器。

当我在 Forge 服务器上运行 ssh -T git@github.com 时,我得到了另一个不再从事该项目的工程师的名字。所以,我认为问题出在 Forge 服务器上,因为它没有我的密钥。所以我尝试了:

ssh-copy-id forge@[ip address] I get the following:

INFO: attempting to log in with the new key(s), to filter out any that 
are already installed

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they 
already exist on the remote system.

(if you think this is a mistake, you may want to use -f option)

我应该强迫它吗?

这是我的 .ssh/config

Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa

[编辑] 所以运行 ssh -vvv git@github.com 给出:

debug1: Authenticating to github.com:22 as 'git'
debug3: hostkeys_foreach: reading file "/home/forge/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file 
/home/forge/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from github.com

【问题讨论】:

  • 如果你的 Git 是为其他用户设置的,那么是的,你绝对应该修复它。
  • 用-f来强制干什么?

标签: git forge


【解决方案1】:

我修复 Forge 以通过 SSH 连接到 GitHub 的步骤如下:

  1. Github Generate SSH Key
  2. Add SSH Key to SSH-agent
  3. Add new ssh key to git hub account

    ssh-keygen -t rsa -b 4096 -C "我的邮箱"

    eval "$(ssh-agent -s)"

    ssh-add ~/.ssh/id_rsa

    ssh -vT git@github.com

    [排除大量技术废话] 嗨[我的用户名]!您已成功通过身份验证,但 GitHub 没有 提供外壳访问。

cat ~/.ssh/id_rsa.pub - 通过设置 > SSH 和 GPG 密钥 > 单击新建 SSH 密钥或添加 SSH 密钥,将其复制并添加到 github 帐户。

【讨论】:

    【解决方案2】:

    当我在 Forge 服务器上运行 ssh -T git@github.com 时,我得到了另一个不再从事该项目的工程师的名字。所以,我认为问题出在 Forge 服务器上,因为它没有我的密钥。

    这是正确的,但有些不完整。更具体地说,当您在 Forge 服务器上运行 ssh -T git@github.com 时,Forge 服务器会向 GitHub 提供 some 密钥。该密钥确实存在于 Forge 服务器和 GitHub 上的上。 GitHub 使用该密钥(无论它是什么)来查明您是谁——以及 GitHub 上存储的内容表明 那个 密钥属于其他工程师。

    ...ssh-copy-id forge@[ip address]

    大概你是从一些拥有你的 GitHub 密钥的机器上运行的。如果是这样,那就合适了。

    [产生]

    /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they 
    already exist on the remote system.
    
    (if you think this is a mistake, you may want to use -f option)
    

    你确实可以使用-f

    我自己做这一切的方式完全不同:我有一个仅用于 GitHub 访问的 ssh 密钥,并配置我打算从中访问 GitHub 的系统:

    $ cat $HOME/.ssh/config
    [snip]
    Host github.com
            IdentityFile ~/.ssh/id.github
            IdentitiesOnly yes
    

    (其中id.github 包含私钥,id.github.pub 包含公钥)。

    我为每个组织使用不同的 密钥对,这可以生成复杂的 .ssh/config 文件,但这意味着我不会将所有内容都提供给每个人。

    【讨论】:

    • 感谢您的全面回答@torek。一旦我创建了另一个 ssh 密钥并将其命名为 github,我将如何使用 ssh-copy-id 在伪造服务器上获取该特定密钥?
    • Forge 建议。请确保将以下 SSH 密钥(出于安全原因我省略了)放在服务器上的 /home/forge/.ssh/authorized_keys 文件和 /root/.ssh/authorized_keys 文件中。当他们说:/root/.ssh/authorized_keys 文件在您的服务器上时,他们的意思是什么(那是我的笔记本电脑吗?)
    • 任何特定用户帐户的authorized_keys 文件是所述帐户允许的密钥,即,如果您拥有该密钥并将其交付给(在这种情况下)Forge,他们会认为您被允许以该用户身份登录。我不确定他们为什么在这里建议/home/forge /root,但是这两个目录(及其包含的authorized_keys 文件)都将存在于Forge 服务器,不在您的笔记本电脑上。这些都不影响 Forge 服务器 GitHub 的登录。
    • 所以我检查了authorized_keys和Forge说要放在那里的ssh密钥。现在我在仪表板中检查了伪造服务器的连接状态,它连接成功。当我单击部署时,它仍然出现此错误:Mon Jul 2 06:30:53 UTC 2018 ERROR: Repository not found. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 我通过电子邮件发送了 Forge 支持,他们只是说:似乎连接的 git 用户无权访问此存储库。
    • 我对 Forge 本身一无所知,因此不知道“点击部署”实际上做了什么。也许这解释了为什么他们说把钥匙放在两个不同的地方。
    猜你喜欢
    • 2021-03-11
    • 2021-09-23
    • 2013-08-30
    • 2016-04-27
    • 1970-01-01
    • 1970-01-01
    • 2014-03-01
    • 2012-08-11
    相关资源
    最近更新 更多