SoureTree Github 克隆项目时报错 Error: Permission denied (publickey)

本文主要是介绍SoureTree Github 克隆项目时报错 Error: Permission denied (publickey),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

目录

      • step1 你可以用下面的命令验证你的连接是否正常
      • step2 确保你有一个正在使用的key
      • step3 生成新的SSH key
      • step4 将你的SSH key加入到ssh-agent里面

这种错误一般代表服务器拒绝了你的连接请求。可能会有很多原因,最常见的🌰是下面这些。

step1 你可以用下面的命令验证你的连接是否正常

$ ssh -T git@github.com
> Hi username! You've successfully authenticated...

如果你是被denied的状态,就显示是denied

step2 确保你有一个正在使用的key

验证你是否生成过私钥并且把它加载进了SSH,

  • 如果你正在使用OpenSSH 6.7 or 更老版本,并已生成并加载过私钥:
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566
$ ssh-add -l
> 2048 a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa (RSA)
  • 如果你正在使用OpenSSH 6.8 or 更新版本,并已生成并加载过私钥:
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566
$ ssh-add -l -E md5
> 2048 MD5:a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa

我在这碰到的情况,可能是之前生成的私钥被下载的🐧的mac管理软件删除了(猜测的,因为没找到)

step3 生成新的SSH key

复制一下文本到你的termial中,用你自己的github email地址替换里面的email地址

#This creates a new ssh key, using the provided email as a label.
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
> Generating public/private rsa key pair.
#When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.> Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
#At the prompt, type a secure passphrase(密码).> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

在这,我设置的密码都是和macbook登陆一样的密码,方便记忆

step4 将你的SSH key加入到ssh-agent里面

Before adding a new SSH key to the ssh-agent to manage your keys, you should have checked for existing SSH keys and generated a new SSH key. When adding your SSH key to the agent, use the default macOS ssh-add command, and not an application installed by macports, homebrew, or some other external source.
在将新的SSH密钥添加到ssh-agent来管理密钥之前,您应该已经检查了现有的SSH密钥并生成了一个新的SSH密钥。将SSH密钥添加到代理agent时,请使用默认的macOS ssh-add命令,而不要使用macports, homebrew, 或其他外部源安装的应用程序。

  1. Start the ssh-agent in the background.
$ eval "$(ssh-agent -s)"
> Agent pid 59566
  1. 如果您使用的是macOS Sierra 10.12.2或更高版本,则需要修改〜/ .ssh / config文件,以将密钥自动加载到ssh-agent中并将密码短语存储在密钥链中。
  • 这里我发现我的mac里面没有这个config文件,我就直接vi新建了一个,粘贴了下面的内容进去。
Host *AddKeysToAgent yesUseKeychain yesIdentityFile ~/.ssh/id_rsa
  1. Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.
    将SSH私钥添加到ssh-agent,并将密码存储在钥匙串中。如果您使用其他名称创建密钥,或者要添加具有其他名称的现有密钥,请使用自己命名的名称替换命令中的id_rsa。
$ ssh-add -K ~/.ssh/id_rsa
  1. 将SSH key添加到你的 GitHub 账户中.
    在这里插入图片描述
    在这里插入图片描述

这篇关于SoureTree Github 克隆项目时报错 Error: Permission denied (publickey)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/637722

相关文章

sky-take-out项目中Redis的使用示例详解

《sky-take-out项目中Redis的使用示例详解》SpringCache是Spring的缓存抽象层,通过注解简化缓存管理,支持Redis等提供者,适用于方法结果缓存、更新和删除操作,但无法实现... 目录Spring Cache主要特性核心注解1.@Cacheable2.@CachePut3.@Ca

SpringBoot通过main方法启动web项目实践

《SpringBoot通过main方法启动web项目实践》SpringBoot通过SpringApplication.run()启动Web项目,自动推断应用类型,加载初始化器与监听器,配置Spring... 目录1. 启动入口:SpringApplication.run()2. SpringApplicat

解决Nginx启动报错Job for nginx.service failed because the control process exited with error code问题

《解决Nginx启动报错Jobfornginx.servicefailedbecausethecontrolprocessexitedwitherrorcode问题》Nginx启... 目录一、报错如下二、解决原因三、解决方式总结一、报错如下Job for nginx.service failed bec

Springboot项目构建时各种依赖详细介绍与依赖关系说明详解

《Springboot项目构建时各种依赖详细介绍与依赖关系说明详解》SpringBoot通过spring-boot-dependencies统一依赖版本管理,spring-boot-starter-w... 目录一、spring-boot-dependencies1.简介2. 内容概览3.核心内容结构4.

在ASP.NET项目中如何使用C#生成二维码

《在ASP.NET项目中如何使用C#生成二维码》二维码(QRCode)已广泛应用于网址分享,支付链接等场景,本文将以ASP.NET为示例,演示如何实现输入文本/URL,生成二维码,在线显示与下载的完整... 目录创建前端页面(Index.cshtml)后端二维码生成逻辑(Index.cshtml.cs)总结

Spring Boot项目如何使用外部application.yml配置文件启动JAR包

《SpringBoot项目如何使用外部application.yml配置文件启动JAR包》文章介绍了SpringBoot项目通过指定外部application.yml配置文件启动JAR包的方法,包括... 目录Spring Boot项目中使用外部application.yml配置文件启动JAR包一、基本原理

Springboot项目登录校验功能实现

《Springboot项目登录校验功能实现》本文介绍了Web登录校验的重要性,对比了Cookie、Session和JWT三种会话技术,分析其优缺点,并讲解了过滤器与拦截器的统一拦截方案,推荐使用JWT... 目录引言一、登录校验的基本概念二、HTTP协议的无状态性三、会话跟android踪技术1. Cook

springboot项目中集成shiro+jwt完整实例代码

《springboot项目中集成shiro+jwt完整实例代码》本文详细介绍如何在项目中集成Shiro和JWT,实现用户登录校验、token携带及接口权限管理,涉及自定义Realm、ModularRe... 目录简介目的需要的jar集成过程1.配置shiro2.创建自定义Realm2.1 LoginReal

idea Maven Springboot多模块项目打包时90%的问题及解决方案

《ideaMavenSpringboot多模块项目打包时90%的问题及解决方案》:本文主要介绍ideaMavenSpringboot多模块项目打包时90%的问题及解决方案,具有很好的参考价值,... 目录1. 前言2. 问题3. 解决办法4. jar 包冲突总结1. 前言之所以写这篇文章是因为在使用Mav

在Linux系统上连接GitHub的方法步骤(适用2025年)

《在Linux系统上连接GitHub的方法步骤(适用2025年)》在2025年,使用Linux系统连接GitHub的推荐方式是通过SSH(SecureShell)协议进行身份验证,这种方式不仅安全,还... 目录步骤一:检查并安装 Git步骤二:生成 SSH 密钥步骤三:将 SSH 公钥添加到 github