Git报错:git@github.com: Permission denied (publickey)

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

1 错误信息

输入指令ssh -T git@github.com测试SSH链接,出现如下报错:

  1. git@github.com: Permission denied (publickey,password,keyboard-interactive).
  2. git@github.com: Permission denied (publickey).
  3. git@github.com's password:,但是即是你输入的是正确的密码,依旧提示Permission denied, please try again.

2 常规解决方法

在网上搜索相关解决方案,可以查到基本上都是说公钥没有配置好,操作如下:

  1. 生成SSH keys:ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "your_email@example.com"
  2. 配置ssh-agent:ssh-agent bashssh-add ~/.ssh/id_rsa.github
  3. 如果是多账号,则生成config:touch ~/.ssh/config
  4. 在GitHub账号页面中:settings -> SSH and GPG keys -> New SSH key

上述详细操作方法可以查阅其他博文,因为这不是本文的重点,很多人可能已经正确的配置了SSH keys,但已经无法正常链接SSH,可以看下面的解决方法。

3 其他解决方法

要测试通过 HTTPS 端口的 SSH 是否可行,请运行以下 SSH 命令:

ssh -T -p 443 git@ssh.github.com

如果你看到:

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

那么说明可以通过 HTTPS 443端口建立的 SSH 连接,接下来编辑~/.ssh/config文件(C:\Users\Admin\.ssh\config),若没有该文件,可以输入如下指令新建一个:

touch ~/.ssh/config 

把下面内容填入该文件:

Host github.com
    Port 443
    HostName ssh.github.com
    User git
    IdentityFile ~/.ssh/id_rsa.github

需要注意的是IdentityFile字段的值要是.ssh文件夹中的GitHub公钥文件名。再输入:

ssh -T git@github.com

将看到:

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

说明问题已经解决了。文章来源地址https://www.toymoban.com/news/detail-785625.html

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

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

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

相关文章

  • git问题:git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

    重装系统后,git push项目时出现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.出现这个问题表示你在尝试将本地代码推送到GitHub时,没有提供正确的公钥,或者你的公钥没有被添加到你的GitHu

    2024年02月21日
    浏览(38)
  • 解决git@github.com:Permission denied (publickey).fatal:Could not read from remote repository.

    1.打开Git Bash。 2.输入 ls -al ~/.ssh 以查看是否存在现有 SSH 密钥。 3.检查目录列表以查看您是否已有公共 SSH 密钥。默认情况下,GitHub 支持的公钥的文件名是以下之一: id_rsa.pub、 id_ecdsa.pub、 id_ed25519.pub。 如果您收到 ~/.ssh 不存在的错误,则说明您在默认位置中没有现有的 SS

    2024年02月12日
    浏览(44)
  • 使用gitee上传代码报错:git@gitee.com: Permission denied (publickey),如何配置GitEE公钥

    git@gitee.com: Permission denied (publickey). Could not read from remote repository.  Please make sure you have the correct access rights and the repository exists. Permission denied (publickey) 没有权限的publickey(公锁) ,出现这错误一般是以下两种原因: 客户端与服务端未生成 ssh key 客户端与服务端的ssh key不匹配 找到

    2024年02月05日
    浏览(40)
  • 终极办法!connect to host port 22: Connection timed out git@ssh.github.com: Permission denied (publickey

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

    2024年02月04日
    浏览(42)
  • 解决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日
    浏览(40)
  • win10下解决git报错 Permission denied(publickey)

    今天在csdn的GitCode新建了一个项目,然后在windows下git clone时出现错误 git@gitcode.net: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 完整报错如下图 直接说结论 因为没有把电脑的SSH public key添加到项目的gi

    2024年02月11日
    浏览(43)
  • 解决GIT问题:git@gitee.com: Permission denied (publickey).fatal: Could not read from remote repository.

    下图是详细的报错信息: 对于这个问题,我们得针对不同的情况来分析,逐步解决这个问题 如果您是刚开始使用git,并且没有生成公钥,我们需要先使用命令来生成公钥 为了更加易懂,给大家额外补充一些SSH的知识 SSH key 的作用: 实现本地仓库和 Github 之间免登录的加密数据

    2024年02月20日
    浏览(41)
  • 解决在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日
    浏览(41)
  • 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日
    浏览(38)
  • 【git问题】git同步 Permission denied (publickey).

    问题描述: 使用git clone 、git pull 等去仓库代码时,会提示 Permission denied (publickey) 。 问题定位: 如果是因为升级了mac系统到Ventura,git clone 、git pull等命令基于ssh协议,macOS Ventura内置使用了OpenSSH_9.0p1,根据OpenSSH发行说明,从OpenSSH 8.8/8.8p1 版本开始,就默认关闭了ssh-rsa算法。

    2024年02月04日
    浏览(53)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包