gpt4 book ai didi

Git推送权限被拒绝(公钥)但成功通过身份验证

转载 作者:太空狗 更新时间:2023-10-29 13:25:06 25 4
gpt4 key购买 nike

我想使用 ssh 将我的提交推送到 github。我明白了

You've successfully authenticated

运行后的消息 ssh -T git@github.com命令,但是当我想推送我的提交时,我得到了这个错误:

Permission denied (publickey). fatal: Could not read from remote repository.

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

我运行 ssh-add -l命令,我得到

4096 SHA256:SREQ0/2G0mT+UxUmpLWmkMramBcFxnl+onFyXgwFENk ~/.ssh/work2_rsa (RSA) 4096 SHA256:gKPZ1Hxzc6eZ/NsgnoPaJsGbdWgQV54bYAXaTym3PfY ~/.ssh/work3_rsa (RSA)

我运行 git remote -v我得到了

origin  git@github.com:H-Ghadirian/UdacitySillySong.git (fetch)
origin git@github.com:H-Ghadirian/UdacitySillySong.git (push)
sillySong git@github.com:H-Ghadirian/UdacitySillySong.git (fetch)
sillySong git@github.com:H-Ghadirian/UdacitySillySong.git (push)

我读了this post .它与我的问题非常相似但是sudo没有解决我的问题。

我也运行 git push -u origin master并得到同样的错误:

Permission denied (publickey).

我还读了Permission denied (publickey). fatal: The remote end hung up unexpectedly for git pull但我的公钥在 .ssh 文件夹中,那不是我的情况

我读了这个页面:Error: Permission denied (publickey)并检查所有。我错过了什么吗?

我该怎么办?

MacOS:塞 pull 利昂

git 版本 2.13.5 (Apple Git-94)

作为this link描述,我加config文件到我的.ssh文件夹并添加

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

给它。

最佳答案

首先检查什么git remote -v返回:

  • 它需要是你拥有的一个 repo 或者你是一个合作者
  • 它必须是正确的 ssh url git@github.com:<you>/<yourRepo.git>
    (而不是 https like in your question yesterday )

明确一点,您需要先在 GitHub 上创建远程仓库:推送到一个不存在的仓库会产生该错误。

通常,ssh url 不工作意味着该 URL 没有按照 ssh 期望的方式编写。
由于 ssh config,ssh 可能需要一个不同的 URL。文件在 ~/.ssh/config .

I run commands with sudo and check repo multiple times.

您没有运行 ssh git@github.com使用 sudi,这意味着您也不需要 sudo用于您的推送命令。

关于Git推送权限被拒绝(公钥)但成功通过身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46383279/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com