解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.

这篇具有很好参考价值的文章主要介绍了解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.首先,判断是否生成了密钥和公钥

1.打开Git Bash。

2.输入ls -al ~/.ssh以查看是否存在现有 SSH 密钥。

3.检查目录列表以查看您是否已有公共 SSH 密钥。默认情况下,GitHub 支持的公钥的文件名是以下之一:id_rsa.pub、id_ecdsa.pub、id_ed25519.pub。

2.没有生成密钥,如果已有密钥请忽略这一步。或者你可以按此操作重新生成一个

如果您收到~/.ssh不存在的错误,则说明您在默认位置中没有现有的 SSH 密钥对,需要创建新的 SSH 密钥对,具体见下一节,这里先讨论有密钥对的情况。

1.打开Git Bash

2.粘贴下面的文本,替换为您的 GitHub 电子邮件地址。

ssh-keygen -t ed25519 -C "your_email@example.com"

(这将使用提供的电子邮件作为标签创建一个新的 SSH 密钥。

   注意:如果您使用的是不支持 Ed25519 算法的旧系统,请使用:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

 3.在出现提示时,键入安全密码

> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

 3.将密钥加入ssh-agent

1.如果您看到列出了想要用来连接到 GitHub 的现有公钥和私钥对(例如id_rsa.pubid_rsa ),则可以将该密钥添加到 ssh-agent。

2.将密钥添加到ssh-agent

$ eval "$(ssh-agent -s)"

3.将您的 SSH 私钥添加到 ssh-agent。如果您使用不同的名称创建了密钥,或者要添加具有不同名称的现有密钥,请将命令中的id_ed25519替换为您的私钥文件的名称。

ssh-add ~/.ssh/id_ed25519

 (注:如果您使用的是 macOS 或 Linux,则可能需要在生成新的 SSH 密钥之前更新 SSH 客户端或安装新的 SSH 客户端。

将硬件安全密钥插入计算机。

打开Git Bash

粘贴下面的文本,替换您在 GitHub 上帐户的电子邮件地址。

ssh-keygen -t ed25519-sk -C "YOUR_EMAIL"

如果命令失败并且您收到错误invalid format,或者feature not supported,您可能正在使用不支持 Ed25519 算法的硬件安全密钥。请输入以下命令。

ssh-keygen -t ecdsa-sk -C "your_email@example.com"

出现提示时,请触摸硬件安全密钥上的按钮。

当系统提示您“输入要保存密钥的文件”时,按 Enter 接受默认文件位置。

> Enter a file in which to save the key (/c/Users/YOU/.ssh/id_ed25519_sk):[Press enter]

 当系统提示您输入密码时,请按Enter

> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

 )

4.将 SSH 公钥添加到您在 GitHub 上的帐户。

$ clip < ~/.ssh/id_ed25519.pub

(如果你的 SSH 公钥文件的名称与示例代码不同,请修改文件名以匹配您当前的设置。复制密钥时,请勿添加任何换行符或空格。 )

5.在任意页面的右上角,点击您的个人资料照片,然后点击“设置”

解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.,git,github

6.在侧边栏的“访问”部分中,单击SSH 和 GPG 密钥。 

解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.,git,github

7.单击新建 SSH 密钥或添加 SSH 密钥。

解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.,git,github

8.在“标题”字段中,为新密钥添加描述性标签。

解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.,git,github

9.选择密钥类型,身份验证或签名。

解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.,git,github选择身份认证 

10.在“密钥”字段中,粘贴您的公钥。

解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.,git,github

11.单击添加 SSH 密钥

4.测试ssh连接

1.打开Git Bash

2.输入以下内容:

$ ssh -T git@github.com

您可能会看到这样的警告:

> The authenticity of host 'github.com (IP ADDRESS)' can't be established.
> ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
> Are you sure you want to continue connecting (yes/no)?

 3.验证您看到的消息中的指纹是否与GitHub 的公钥指纹匹配。如果是,则输入yes

公钥指纹在你将公钥加入github的时候会显示,如下图:解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.,git,github

) 

> Hi USERNAME! You've successfully authenticated, but GitHub does not
> provide shell access.

出现此语句,说明成功 ,就可以上传代码了。文章来源地址https://www.toymoban.com/news/detail-659161.html

到了这里,关于解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • git 报错:git@github.com: Permission denied (publickey).fatal: 无法读取远程仓库。

    起因: 我输入git push -u origin master 想要push到github 显示 git@github.com: Permission denied (publickey). fatal: 无法读取远程仓库。 请确认您有正确的访问权限并且仓库存在。 那么我们 第一步: 检查SSH密钥配置不正确: 确保你的本地计算机上配置了正确的 SSH 密钥。你可以通过以下步骤检

    2024年02月04日
    浏览(52)
  • 解决git@github.com:Permission denied (publickey). Could not read from remote repository. Please make s

    这个错误通常表示没有正确的权限来访问该 Git 仓库。 为了解决GitHub上的权限问题,需要执行以下步骤: 打开命令行终端(例如Git Bash)并输入以下命令: 将公钥添加到GitHub帐户中, 执行以下步骤: 在“Title”字段中为新密钥提供一个描述性标题。 将“Key”字段中的公钥粘

    2024年02月06日
    浏览(42)
  • git克隆报错:Permission denied (publickey).fatal: Could not read from remote repository解决办法

    Permission denied (publickey).fatal: Could not read from remote repository 1、问题解决首先参考文章 例如:缺少公钥解决办法 2、生成公钥报错 ssh-keygen -t rsa -C ‘邮箱’ 生成公钥时,报错如下: 解决办法: 需要换到C盘的C:UsersASUS.ssh目录下,再右键Git Bash Here 输入命令: ssh-keygen -t rsa -C \\\'

    2024年02月04日
    浏览(49)
  • Git报错:git@github.com: Permission denied (publickey)

    输入指令 ssh -T git@github.com 测试SSH链接,出现如下报错: git@github.com: Permission denied (publickey,password,keyboard-interactive). git@github.com: Permission denied (publickey). git@github.com\\\'s password: ,但是即是你输入的是正确的密码,依旧提示 Permission denied, please try again. 。 在网上搜索相关解决方案,

    2024年02月02日
    浏览(50)
  • 【git】git@github.com: Permission denied (publickey).报错问题

    本媛开发,会经常性用到gitee GitHub两个库 毕竟国内项目转战仓到gitee, 但是国外原框架还是GitHub居多 于是就出现连接pull-push经常性切换问题 这个报错是因为本地两个仓都有ssh公共私有密钥导致的 2.1.1 是因为首次本地联通没有配置密钥,或者配置错误? 如果是因为第一次配

    2024年02月11日
    浏览(48)
  • git报错:Permission denied (publickey). fatal: Could not read from remote repository.

    背景 :由于新换了电脑,新装了git,所以在用git拉取代码的时候就出现了标题一样的错误 ternimal下出现下面错误: Permissiondenied (publickey). fatal:Could not read from remote repository. Pleasemake sure you have the correct access rights and the repository exists. 分析原因 : 原因是由于你在本地(或者服务

    2024年02月05日
    浏览(47)
  • 解决在linux上git clone 时报错 git@gitee.com: Permission denied (publickey). Could not read from remote repo

    今天在gitee上看到一个比较感兴趣的项目,于是就想下载下来研究研究,结果git clone 克隆的时候报错了,报错如下: git@gitee.com: Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists. Permission denied (publickey) 没有权

    2024年02月11日
    浏览(46)
  • Git push异常:Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password) fatal: Could not read

    在使用新的gitlab仓库迁移旧代码时,当push代码,报了如下异常: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password) .fatal: Could not read remote repository. 在git bash下 1.先清楚本地旧的账号密码: git config --global --unset credential.helper 2.重新设置用户名称和邮箱 git config --global user.nam

    2024年03月17日
    浏览(50)
  • Permission denied (publickey). fatal: Could not read from remote repository.

    将本地代码推送到远程分支报错:Permission denied (publickey). fatal: Could not read from remote repository. 确保已经添加了正确的 SSH 密钥。可以使用以下命令检查 SSH 密钥是否已经添加: 如果看到消息 “Hi [username]! You\\\'ve successfully authenticated, but GitHub does not provide shell access.” ,则表示已成

    2023年04月18日
    浏览(32)
  • 终极办法!connect to host port 22: Connection timed out git@ssh.github.com: Permission denied (publickey

    过了个周末git突然用不了了,在拉代码的时候突然报错连接超时,又报错说没有权限,这就很烦了 在百度了很久以后尝试了各种办法,重新生成pub_key,重装git等等都没能解决,最后询问了公司大佬,困扰了一个上午的问题终于解决了 先说说百度上的解决办法: 使用命令 s

    2024年02月04日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包