起因:

我输入git push -u origin master 想要push到github

git push -u origin master

显示

git@github.com: Permission denied (publickey).

fatal: 无法读取远程仓库。 请确认您有正确的访问权限并且仓库存在。

如何解决的呢:

那么我们第一步:

检查SSH密钥配置不正确: 确保你的本地计算机上配置了正确的 SSH 密钥。你可以通过以下步骤检查和配置:

查看是否存在 SSH 密钥:

ls -al ~/.ssh

如果没有 SSH 密钥,或者你希望创建新的密钥,可以使用以下命令生成:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# 替换 "your_email@example.com" 为你在 GitHub 上注册的邮箱地址。

第二:

将 SSH 密钥添加到 SSH 代理:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

注意:这里面的id_rsa是私钥,有后缀的那个.pub是公钥,公钥不在这添加,在github上面添加

Logo

鸿蒙生态一站式服务平台。

更多推荐