有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,GitHub存储库存在,我不知道现在该做什么。
> git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,GitHub存储库存在,我不知道现在该做什么。
> git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
当前回答
对我来说,我试过这个
eval "$(ssh-agent -s)"
然后我就跑
ssh-add ~/.ssh/path-to-the-keyfile
为了生成密钥,你可以运行
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
这将生成一对密钥(Public和private)。
您可以将此密钥存储到github以了解更多信息,添加一个新的SSH密钥到您的github帐户
我希望它能帮助到其他人:)
其他回答
我想补充一些我的发现:
如果您正在使用GitBash,那么请确保SSH密钥存储在~/. SSH /id_rsa中。
默认情况下,git会搜索~/。ssh/id_rsaas ssh密钥的默认路径。
甚至文件名id_rsa也很重要。如果您将SSH密钥保存在另一个文件名或路径中,它将抛出Permission Denied(publickey)错误。
我也遇到了这个问题,因为我使用了几个GIT帐户,以及工作和大学的不同帐户,这对我来说很有效:
->进入您的SSH配置
cd ~/.ssh/
vim config
->复制下面的块,并填写您想要推送到/with的主机和用户
Host [Hostname]
User [User]
PubkeyAcceptedAlgorithms +ssh-rsa
HostkeyAlgorithms +ssh-rsa
我得到这个问题的几个主机名,所以现在我有几个这些配置在我的ssh配置文件。
您可以使用Https url登录
我猜你是试图登录SSH url 当你说git push,如果它只要求密码,考虑你是通过ssh连接。最好使用HTTP url。
如果您在连接您的企业Github帐户时遇到问题,请按照以下步骤进行
解决方案1
ERROR: git@github.com: Permission denied (public key). fatal: Could not read
from remote repository. Please make sure you have the correct access
rights
解决方案(OSX)
打开终端并执行以下命令 $ CD ~ $ sudo su ssh - keygen美元 输入要保存密钥的文件(/var/root/.ssh/id_rsa): $ id_rsa Enter passphrase(空表示没有passphrase): $ hit Enter 再次输入相同的密码:$ hit Enter $ CD ~/.ssh $ cat id_rsa.pub 复制显示内容。 打开GitHub单击您的配置文件图标设置>SSH和GPC密钥 单击新的ssh键按钮 输入您复制的任何标题和键 检查您的问题是否已经解决
解决方案2
ERROR 2: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.
remote: See https://github.compnay.com/settings/tokens or https://github.compnay.com/settings/ssh
fatal: unable to access 'https://github.company.com/repo/app.git/': The requested URL returned an error: 403
密码认证支持已于2021年8月13日移除。请改用个人访问令牌。
https://namespaceit.com/blog/remote-support-for-password-authentication-was-removed-on-august-13-2021-please-use-a-personal-access-token-instead
使用Https是可以的,运行git config——global credential。帮助wincred创建一个Github凭据帮助存储您的凭据为您。如果这不起作用,那么您需要编辑.git目录中的配置文件,并将原始文件更新为https url。
查看github文档的链接。