【问题标题】:cannot access personal github from work laptop无法从工作笔记本电脑访问个人 github
【发布时间】:2022-02-06 21:42:38
【问题描述】:

我在我的工作笔记本电脑 (ssh-keygen -t ed25519 -C "me@my-personal-email.org") 上生成了一个 SSH 密钥,并将其添加到我的个人存储库的 SSH 密钥列表中。然而,当我尝试 git push 到这个个人回购(从我的工作笔记本电脑上)时,我收到了这样的信息:

ERROR: Repository not found.
fatal: Could not read from remote repository.

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

我还将这些行添加到 repo .git/config:

[user]
    name = MY NAME
    email = me@my-personal-email.org

...我得到同样的错误。

repo 确实存在,我以为我已经设置了访问权限...我会遗漏什么?

【问题讨论】:

  • user.nameuser.email 设置是您可以随时更改的任意字符串,并且不用于身份验证。要了解身份验证如何与 ssh 一起工作,请参阅例如 this answer。要调试 ssh 身份验证,请考虑使用ssh -Tv;例如,请参阅here

标签: git github ssh


【解决方案1】:

检查您是否已完成将 SSH 密钥添加到 SSH 代理的步骤:

# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566

然后

$ ssh-add ~/.ssh/id_ed25519

基本上,您需要告知git,您将使用哪个私钥进行git 连接。

Host One
    HostName ssh.github.com
    IdentityFile ~/.ssh/id_rsa
    User git

Host Two
    HostName ssh.<enterprise>.github.com
    IdentityFile ~/.ssh/id_rsa
    User git

参考文献

【讨论】:

  • 这些页面似乎在告诉我如何在 all 情况下设置 ssh。但是我只想在连接到我的个人 github 帐户时使用这个新的 ssh 密钥,我只会在该特定目录中运行 git 时这样做。当我使用我的工作 github 帐户时,你能确认这些解决方案不会影响 git 吗?
  • 通过git remote -v检查你的git远程,然后会根据~/.ssh/config中设置的主机获取SSH密钥
  • git remote -v 看起来是正确的:它给出了 githib 上 repo 的地址。没有 ~/.ssh/config 文件。 p.s.我的时区已经晚了,所以我可能有一段时间不会再回复你了。
  • 当然彼得,配置文件告诉 git 哪个键和主机匹配。您可以尝试使用所需的值更新它们,以便仅使用与相应主机匹配的私钥与 git ssh 服务器交互。
猜你喜欢
  • 1970-01-01
  • 2023-01-13
  • 1970-01-01
  • 1970-01-01
  • 2012-12-19
  • 1970-01-01
  • 1970-01-01
  • 2013-08-23
  • 2018-06-20
相关资源
最近更新 更多