为什么git push适用于一次回购,而不适用于';你不为别人工作吗?git@github.com:权限被拒绝(公钥)

为什么git push适用于一次回购,而不适用于';你不为别人工作吗?git@github.com:权限被拒绝(公钥),git,github,Git,Github,我使用GPG设置Github访问权限。我今天创建了新的回购协议,遇到了这样的问题 git push origin main Warning: Permanently added the RSA host key for IP address '140.82.999.4' to the list of known hosts. git@github.com: Permission denied (publickey). fatal: Could not read from remote repos

我使用GPG设置Github访问权限。我今天创建了新的回购协议,遇到了这样的问题

git push origin main
Warning: Permanently added the RSA host key for IP address '140.82.999.4' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
遥远的

git remote -v
origin  git@github.com:balboa/createreactapp.git (fetch)
origin  git@github.com:balboa/createreactapp.git (push)
从我的另一份回购协议来看,一切正常

git commit -m "signup changed"
[master b590077] signup changed
 3 files changed, 8 insertions(+), 5 deletions(-)
我在Ubuntu 20.04上


如何解决新回购的权限问题?

如果在生成RSA密钥后不将公钥添加到ssh代理,则可能会出现此问题

首先,, 添加所需的公钥(~/.ssh/id\u rsa.pub) 到你的github帐户

这个问题可以通过运行这些命令来解决

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/<required-key>.pub 
eval“$(ssh代理-s)”
ssh add~/.ssh/.pub

这将向ssh代理添加公钥,并且不会显示“无法从远程存储库读取”的错误消息。

如果在生成RSA密钥后不向ssh代理添加公钥,则可能会发生此问题

首先,, 添加所需的公钥(~/.ssh/id\u rsa.pub) 到你的github帐户

这个问题可以通过运行这些命令来解决

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/<required-key>.pub 
eval“$(ssh代理-s)”
ssh add~/.ssh/.pub

这会将您的公钥添加到ssh代理,并且不会显示“无法从远程存储库读取”的错误消息。

您需要检查
.git/config
~/.gitconfig
~/.ssh/config
文件,以查看它在何处指定要用于相应库的ssh密钥。您需要检查
.git/config
~/.gitconfig
~/.ssh/config
文件,以查看它在何处指定要用于相应库的ssh密钥。