Permission denied (publickey). fatal: Could not read from remote repository.问题法解决方案

Could not read from remote repository.Please make sure you have the correct access rights.解决方法 我们在使用git clone 或其他命令的时候,有时候会遇到这类问题,如图:fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.fatal: Could not read from remote reposi... 阅读详情
AI摘要

本文介绍了如何解决在尝试通过SSH克隆Git仓库时遇到的'Permission denied (publickey)'错误。问题源于SSH公钥信息丢失或不匹配。解决方案包括在Linux和Windows环境下重新生成SSH密钥对,将新公钥添加到Git托管平台(如Gitee或GitHub)的SSH设置中,并处理可能的'known_hosts'警告。经过这些步骤,成功实现了仓库的克隆。

Permission denied (publickey). fatal: Could not read from remote repository.问题法解决方案

0 写这个的原因是,本来很简单的一个问题,我看了一下网上的帖子,大部分都是在ctrl-c/v加胡说八道,也不注明出处,诶…


1 报错分析

今天在gitee上面准备clone一个项目,由于我使用的云服务器很久没用了,出现了以下报错:

[root@VM-4-16-centos home]# git clone git@gitee.com:heiyueGit/springboot-flowable.git demo-app
Cloning into 'demo-app'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

原因翻译过来就是:“拒绝服务(公共秘钥)”,也就是说由于ssh公钥的某些问题导致连接失败,因此我查看了以下我的gitee的ssh设置(gitee网页点头像-设置-ssh公钥)如下:

在这里插入图片描述
……发现以前的公钥信息被删除了,这就是导致连接失败的原因。
接下来,我们在使用ssh连接一下测试

[root@VM-4-16-centos .ssh]# ssh -t git@gitee.com
Permission denied (publickey).
[root@VM-4-16-centos .ssh]# ssh -tv git@gitee.com
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
……(省略)……
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

……大致意思就是找来找去都没找到publickey,所以连接会失败

2 解决方案

既然找到了原因,那我就不具体分析了,直接重新生成ssh密钥对就行了,然后把该密钥对的公钥部分设置到上面那个地方就行了!
操作过程我尽力做到面面俱到,因此下面的操作兼顾了win和linux平台,兼顾github和gitee!

2.1 Linux

[root@VM-4-16-centos ~]# cd ~/.ssh  
[root@VM-4-16-centos .ssh]# ll
total 0
[root@VM-4-16-centos .ssh]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:aD92e78/rhnpxF2DSVmMkJfEMvTbJWnMNxkczakdKJk root@VM-4-16-centos
The key's randomart image is:
+---[RSA 2048]----+
|          .oB.*=+|
|           E.Oo*=|
|            =+Oo+|
|       .    .o=+o|
|      o S    + o.|
|     . .    . o o|
|        + .  = . |
|       . o .+ o. |
|          .. ==+o|
+----[SHA256]-----+
[root@VM-4-16-centos .ssh]# ll
total 8
-rw------- 1 root root 1679 May 21 22:20 id_rsa
-rw-r--r-- 1 root root  401 May 21 22:20 id_rsa.pub
[root@VM-4-16-centos .ssh]# cat id_rsa.hub
-bash: caid_rsa.hub: command not found
[root@VM-4-16-centos .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABA(马赛克)QDu7haN1azW4SkcbM8zn+fV7bdr56MTw1gMlQSl1Bfh2h2ky0CszAasSj3L1yrw8RJYj5YGavYgTfQ4Dtxfc5I9X4Shk0k/Y94BklMxlNhb1uq8GEBgmFMm(马赛克)/lzfyk7QYMqxdYlFu7T7ku+vFHh2ZBduTrLV9iqiPXetJxqJ5EGvMaQxfKdn8u+Al8+99bi8ObBFAjN1G/DrCxIIjg+fvZ root@VM-4-16-centos
[root@VM-4-16-centos .ssh]# 
  1. 进入~/.ssh目录,里面应该是什么都没有(有其他的ssh密码要信息也是正常的)
  2. ssh-keygen 生成ssh密钥对,一路回车就可以了,生成的密钥对拥有默认名称 id_rsa和id_rsa.pub,pub那个就是公钥的意思。
  3. 复制公钥信息
  4. (对于gitee的操作)进入gitee或gitee密钥对设置页面,标题随便,公钥粘贴进来(一定要完整),确定4. (对于github的操作)和上面一模

在这里插入图片描述在这里插入图片描述

  1. 测试
[root@VM-4-16-centos .ssh]# ssh -t git@gitee.com
Warning: Permanently added 'gitee.com,212.64.62.183' (ECDSA) to the list of known hosts.
Hi imoder! You've successfully authenticated, but GITEE.COM does not provide shell access.
Connection to gitee.com closed.

[root@VM-4-16-centos .ssh]# ssh -t git@github.com
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Hi imoderiii! You've successfully authenticated, but GitHub does not provide shell access.
[root@VM-4-16-centos .ssh]# 

……有没有看到successfully 。ok(警告先不管,后面再说!)

clone一下试试?

[root@VM-4-16-centos home]# git clone git@gitee.com:heiyueGit/springboot-flowable.git
Cloning into 'springboot-flowable'...
remote: Enumerating objects: 899, done.
remote: Counting objects: 100% (899/899), done.
remote: Compressing objects: 100% (694/694), done.
remote: Total 899 (delta 192), reused 816 (delta 166), pack-reused 0
Receiving objects: 100% (899/899), 4.17 MiB | 0 bytes/s, done.
Resolving deltas: 100% (192/192), done.

……解决了有没有。

2.2 wins

  1. 打开你的cmd或者git的bash,如下操作,
iModer@DESKTOP-G2HBVIK MINGW64 /f
$ ssh-keygen.exe
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/John/.ssh/id_rsa):
Created directory '/c/Users/John/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/John/.ssh/id_rsa.
Your public key has been saved in /c/Users/John/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:YFDOEXuUjGfbECTlLfB9FRK1XXFQGukRbOhovMqpu6I iModer@DESKTOP-G2HBVIK
The key's randomart image is:
+---[RSA 3072]----+
|    ..**=o  o=BB=|
|     +.O*o  .o==o|
|      *o==oo.oo..|
|     . o..=.. .  |
|        S. .     |
|          .      |
|       . o       |
|    .   +        |
|  E. .++         |
+----[SHA256]-----+

……生成ssh密钥对,唯一的不同就是……额,生成的目标文件夹不同,在/c/Users/yours/.ssh’下,然后复制下公共秘钥,后面的操作就和前面一样了。

3 Warning: Permanently added ‘gitee.com,212.64.62.183’ (ECDSA) to the list of known hosts.的解决方案

其实建议可以在进行域名解析时将相应的域名设置为永久,也就是在你的hosts文件中显示配置一下:
linux下hosts文件为**/etc/hosts**
在这里插入图片描述
wins的hosts文件应该在C:\Windows\System32\drivers\etc文件夹下?(你可以百度一下),添加的内容和上面一模一样,保存退出就可以了。
测试一下:

[root@VM-4-16-centos home]# ssh -t git@gitee.com
Hi imoder! You've successfully authenticated, but GITEE.COM does not provide shell access.
Connection to gitee.com closed.

大功告成!,溜了溜了。

fatal: Could not read from remote repository. Please make sure you have the correct access rights 使用git clone命令从github上同步github上的代码库时,如果使用SSH链接,系统会报下面的错误:Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository... 阅读详情

相关推荐

github上传项目的时候报出git@github.com: Permission denied (publickey). fatal: Could not read from remote repo

前言 会不会有程序员小伙伴在刚开始使用github的时候上传项目的时候困难重重,但是又基于自己本身的知识量不够缺无法解决,昨天本人小白第一次把项目上传到github的时候就发现无论如何都无法上传,但今天终于可以解决了,我在这里总结一下是什么原因。 问题 第一句报错: fatal: remote origin already exists. 远程起源已经存在。 第二句报错: git@github....

weixin_44394753的博客 3万+

Permission denied (publickey). fatal: Could not read from remote repository.

Git的SSH公钥是用于通过SSH协议进行身份验证和授权的公钥,它允许在Git版本控制系统中访问需要身份验证的仓库。3.在左侧菜单中选择“SSH and GPG keys”(SSH和GPG密钥),然后单击“New SSH key”(新SSH密钥)按钮。否则,表示没有访问远程仓库的权限,可能是因为没有正确配置 SSH 密钥或没有在 Github 上将公钥添加到的帐户中。4.在“Title”字段中提供一个描述性的名称,然后将刚刚生成的SSH公钥(.pub)的内容复制到“Key”字段中。

liulanba的博客 1万+

【Gerrit】正确添加了SSh key 仍报错 Permission denied (publickey). fatal: Could not read from remote repository

当我们在部署新的开发环境时在使用Gerrit clone代码的时候,你会发现报错,错误信息大概是: Permission denied (publickey). fatal: Could not read from remote repository.OpenSSH从8.8版本开始由于安全原因开始弃用了rsa加密的密钥。 因为OpenSSH认为rsa破解成本太小了,有风险就给禁用了。 你可以通过命令: 如: 去查看Gerrit服务器的OpenSSH的版本号, 如果≥8.8,就可以用这个方法。可以使用ed2

节省钱的博客 7683

Permission denied (publickey).fatal: Could not read from remote repository.

生成密钥:ssh-keygen -t rsa -C "email",其中 email是github的登陆邮箱,然后一直按回车键;同级目录下会出现密钥。第三步:登录github账号,进入个人设置User settings--->ssh keys-->new ssh key 添加密钥即可。因而需要获取本地电脑公钥,然后登录github账号,添加公钥至github就可以了.原因:服务器公钥(publickey)未添加至。第二步: 进入id_rsa.pub, 复制密钥。

weixin_42148389的博客 3483

Ubuntu系统提示错误:Permission denied (publickey). fatal:Could not read from remote repository.问题解决办法

最近在新安装的Ubuntu 16.04系统中clone github项目时,遇到拒绝访问的问题,特此与大家分享该问题的解决办法。 执行命令: git clone --recursive git@github.com:leggedrobotics/darknet_ros.git 报错(如图): Warning: Permanently added the RSA host key for IP a...

Timothy_Liuu的博客 2668

出现Permission denied (publickey). fatal: Could not read from remote repository.Please make sure 解决方法

在首次连接时,系统会显示Gitee服务器的SSH密钥指纹。Gitee的SSH密钥指纹可以在Gitee网站上找到。以上步骤可以确保您的本地系统已生成有效的SSH密钥,并将其配置到Gitee服务器中,从而解决SSH密钥验证问题。这个问题的原因是因为Git使用SSH协议进行连接,而在首次连接时,系统会尝试验证Gitee服务器的SSH密钥。确保用于生成密钥的电子邮件地址是与Gitee帐户关联的地址。为了解决这个问题,我们需要确认Gitee服务器的SSH密钥指纹是否真实有效,并在本地生成并配置SSH密钥。

码农研究僧的博客 2972

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

今天用idea提交代码到github上,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. 一:原因分析 Permission denied (publickey) 没有权限的public.

小泽 8万+

读书笔记|智能运维系统落地方案

对于互联网公司来说,系统复杂化导致的人工运维成本激增已经是普遍现象,采用智能运维是行之有效的应对策略。智能运维的核心思想是利用算法来处理海量运维数据,积累运维经验,从而代替人工思考判断,以自动化的过程实现风险的预防、发现、定位和处理。而智能运维系统是其中的重中之重,但建设企业应用智能运维系统,不是应用运维部独立规划设计就可以完成的,它需要业务、产品、开发、基础设施运维多部门协同才能顺利实施。 那么,作为运维人员,您是否了解智能运维系统的架构?如果参与规划建设智能运维系统,该怎么着手呢?下面我们立足实际需求

xiaoshuaca的博客 685

【Git】解决方案:Permission denied (publickey). fatal: Could not read from remote repository.

Permission denied (publickey). fatal: Could not read from remote repository.

洗棉花糖的浣熊的博客 2953

从零到一:基于Docker与Gewechat协议,打造高可用微信AI助手

本文提供了一份从零开始的实战指南,详细讲解如何利用Docker容器化技术与Gewechat协议,构建一个高可用、低风险的微信AI助手。通过整合Dify AI平台,您可以为微信机器人注入大语言模型的智能,实现自动问答、知识库查询等高级功能,显著提升个人或团队在微信场景下的沟通与信息处理效率。

weixin_29280657的博客 161

安装m_map以及用matlab绘制高精度海岸线地图

#如何用matlab绘制高精度海岸线地图

qq_38512775的博客 1万+

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. Please make sure you have the correct access rights and the repository exists. Failed during: git fetch or...

运用之妙,存乎一心 5万+

yolov8 PTQ和QAT量化实战(源码详解)

量化():是指将高精度浮点数(FP32)转换为低精度(8bit或4bit)整数的过程,它是模型部署中的一种非常重要的优化方法,可以在较少的精度损失下,大幅提供神经网络的效率和性能。目前主流的神经网络量化方式有PTQ和QATPTQ是训练后量化(),无需数据集和训练,直接量化模型权重QAT是量化感知训练(),量化后需要在数据集上继续微调训练。QAT过程中,我们首先需要选择哪些层需要进行finetune训练,并利用FP32对应层的输出作为监督进行训练。

@bangbang的博客 5332

解决方案:stderr: Permission denied (publickey). fatal: Could not read from remote repository

阿里云Code配置Jenkins SSH 认证失败,出错解决方案

极客星云-优快云博客 4746

零基础学习simulink-- 基于自适应模糊PID控制的直流电机速度控制系统

通过上述代码实现,您可以逐步创建和搭建一个基于自适应模糊PID控制的直流电机速度控制系统。该系统能够根据电机的状态和误差实时调整PID参数,确保电机速度稳定在设定范围内。自适应模糊PID控制具有较强的鲁棒性和适应性,能够在存在不确定性和扰动的情况下提供快速且精确的控制性能。Simulink提供了强大的建模和仿真工具,使得控制系统工程师能够快速构建复杂的控制算法,并将其应用于实际工程中。直流电机建模:建立直流电机的动态模型,包括电枢电压、电流、转速和负载扭矩。自适应模糊PID控制器设计。

amy_mhd的博客 413

Ardupilot飞控姿态角与姿态角速度控制过程分析(超长篇)

目录 目录 摘要 1.代码控制过程分析 摘要 本节主要记录自己学习ardupilot飞控代码的姿态角速度的控制过程 1.代码控制过程分析 可以看出:AC_AttitudeControl *attitude_control; //指针对象 virtual void rate_controller_run() = 0;是AC_AttitudeContro...

陌城烟雨 1万+

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时,没有提供正确的公钥,或者你的公钥没有被添加到你的GitHub账户中。

小夏尔的博客 4004

Linux C/C++ or 嵌入式面试之《C/C++笔面试系列》(10) C++ 前置后置增减运算符重载形式与比较

C语言的++、–运算符在此不讨论。 文章目录1、前置后置增减运算符重载的形式2、前置和后置运算符的性能比较 1、前置后置增减运算符重载的形式 自增运算符“++”和自减运算符“–”分别包含两个版本。即运算符前置形式(如 ++x)和运算符后置形式(如 x++),这两者进行的操作是不一样的。因此,当我们在对这两个运算符进行重载时,就必须区分前置和后置形式。C++根据参数的个数来区分前置和后置形式。如果按照通常的方法来重载 ++ 运算符(即作为成员函数重载时不带参数,或者作为非成员函数重载时带有一个参数),那么重载

二进制君 5834

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

在使用git拉取文件时说没有权限,错误如下图所示。错误原因是没有进行SSH密钥是设置。 解决方法:(linux环境下),其他环境请转到它的主页面。 1、检测是否存在ssh keys ls -al ~/.ssh 如果列出来三个文件,说明存在,那进入下一步。否则,要自己生成密钥。 2.创建一个新的SSH密钥并添加到SSH代理中 a、创建新的SSH密钥 ssh-keygen...

NEVERGUVEIP的博客 7497

【大模型学习】第二十四章 生成式人工智能(GAI)简介

‌的AI技术,其核心目标是通过学习数据中的规律,生成与训练数据类似但全新的文本、图像、音频、视频甚至代码。生成式人工智能(GAI)是一类能够‌。

以实战经验介绍行业知识 1639

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

解决GIT问题:git@gitee.com: Permission denied (publickey).fatal: Could not read from remote repository.

​生成 SSH key① 打开 Git Bash② 粘贴如下的命令,并将 your_email@example.com 替换为注册 Github 账号时填写的邮箱:ssh-keygen -t rsa -b 4096 -C "your_email@example.com"③连续敲击3次回车,即可在C:\Users\用户名文件夹\.ssh 目录中生成id rsa 和 id rsa.pub 两个文件配置 SSH key① 使用记事本打开 id_rsa.pub 文件,全选复制里面的文本内容②在浏览器中登录 Gith

分享自己的经验、IT技术,愿在博客中遇见更好的自己 8646

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Permission denied (publickey). fatal: Could not read from remote repository

今天在上传项目到码云的时候,出现了上述描述的错误。这个应该是很多github新手经常出错的问题,其实就是没有在你github上添加一个公钥。 报错截图如下: $ git push git@gitee.com:wupengwei0726/demo2.git master git@gitee.com: Permission denied (publickey). fatal: Could not re...

qq_36343904的博客 3460

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

bug解决:Permission denied (publickey). fatal: Could not read from remote repository;SSH key添加方法

(base) [ec2-user@ip- workspace]$ git clone git@github.com:hamigua2019/minerl.git Cloning into 'minerl'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository e

weixin_40945354的博客 596

解决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 场景: 使用SSH地址下载GitHub项目报错,原因是没有配置SSH keys 使用的命令: git clone git@github.com:zhangbeizhen/demo-co...

zhangbeizhen18的博客 2万+

【IDEA-gitee】Permission denied (publickey). fatal: Could not read from remote repository

在IDEA中从Gitee拉取代码时出现这种问题,于是搜到了下面这篇文章,成功解决 原文地址:Permission denied (publickey). fatal: Could not read from remote repository. Git clone git@git.coding.net:账户 /项目.git 上面以SSH方式访问用项目出现权限问题 Permissionden...

Japathy 2114
上一篇: 基于SSM的WebSocket环境搭建与API学习
imoder
博客等级 码龄9年 1粉丝 2原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值