git clone 解决Permission Denied (publickey)问题

本地git bash 使用git clone [email protected]:***.git方式下载github代码至本地时需要依赖ssh key,遇到权限不足问题时一般都是SSH key失效或者SSH key不存在,重新创建SSH key一般就可以解决问题;

步骤一、检查本地ssh key是否存在

1、windows下 开始 -- 搜索框输入 git bash,打开git bash窗口;

2、git base窗口中输入指令 ls ~/.ssh/ 来检查ssh key是否存在;

3、如果key不存在则按照步骤二重新生成,ssh key已存在则跳过步骤二,执行步骤三;

步骤二、生成ssh key

1、继续步骤一的git bash窗口执行指令:

ssh-keygen -t rsa -b 2048 -C "你自己的邮箱地址"

修改邮箱地址为你自己的邮箱地址,注意此处邮箱地址前后的双引号为英文格式双引号;

2、指令执行后页面提示:

Generating public/private rsa key pair.
           Enter file in which to save the key (/c/Users/***/.ssh/id_rsa):

***表示你自己的当前登录用户名,不做修改直接回车,会将生成的rsa文件保存为默认名称

再次回车提示:

Enter passphrase (empty for no passphrase): 
         Enter same passphrase again: 
         提示设置提交/l拉取代码到Github时需要的密码及确认密码;

设置密码后再次回车提示Your identification has been saved in.... 即表示ssh key生成成功;

步骤三、添加sshkey至ssh-agent

1、执行eval “$(ssh-agent -s)”确认ssh-agent处于开启状态,打印pid... 表示启用中;

2、执行指令ssh-add ~/.ssh/id_rsa 添加ssh key至ssh agent,此步会要求输入步骤二设置的密码;

需要注意的是此处可能报错:Could not open a connection to your authentication agent,我的解决办法是关掉当前git                  bash窗口,重新以管理员身份运行git bash 即解决问题;

步骤四、添加ssh key至guthub

1、登录https://github.com/,在页面右上角自己头像右边箭头处右击,弹框中进入setting功能;

2、setting界面右边菜单选择SSH and GPG keys,选择新建SSH keys,

保存即可;

步骤五:git clone下载代码

步骤结束,此时再尝试本地使用git clone方式下载代码即可;
---------------------
作者:scanklm
来源:CSDN
原文:https://blog.csdn.net/sxg0205/article/details/81412921
版权声明:本文为博主原创文章,转载请附上博文链接!

原文地址:https://www.cnblogs.com/whowhere/p/10041447.html

时间: 2024-08-28 07:37:27

git clone 解决Permission Denied (publickey)问题的相关文章

centos: git clone提示Permission denied publickey 问题

问题: Initialized empty Git repository in /data1/mouxuan/fastsocket-private/.git/ Permission denied (publickey). fatal: The remote end hung up unexpectedly 解决步骤: 1.cd ~/.ssh 2.ssh-keygen -t rsa -C [email protected] 遇到 提示一路 回车 遇到有Y 输入Y 3.ssh-add id_rsa

ubuntu下git clone 出现Permission denied (publickey).

今天在ubuntu上使用git 克隆 github上面的库,一直权限拒绝Permission denied (publickey). 公钥绑了好几次,都不行: 最后怀疑是git配置公钥地址有问题:打开 /etc/ssh/ssh_config: 修改配置:IdentityFile -/.ssh/id_rsa    ->  IdentityFile /home/llh/.ssh/id_rsa 成功!!! 怀疑原因:可能因为ubuntu使用sudo 权限时,用户发生变化使得-/.ssh/id_rsa

ubuntu 下使用git/github [Error: Permission denied (publickey) ]

1.背景 之前因为误删了文件,导致程序和软件都被删除,损失是心疼的,里面有这好几个月的练习代码,一步一步走来的,就这样没了. 为了避免重蹈覆辙,于是准备使用git版本控制.在此记录一下,在配置git时候遇到的一些小问题. 2.准备工作 本机系统:ubuntu 14.04 整个配置过程是在廖雪峰的官方网站的指导下进行,因为其讲解较为详细,语言通俗易通, 按照流程配置基本没有问题.但因为环境和操作的不同,会出现问题也是在所难免的. 3.遇到的问题 在git创建仓库–>初始化–>add添加到暂存区–

git 时 出现 Permission denied (publickey).

https://blog.csdn.net/awp0011/article/details/73368481 第一次使用github.com在本地 执行 git clone [email protected]:xxxxx/xxxxx.git 异常信息: Permission denied (publickey). fatal: Could not read from remote repository. 原因是SSH 登录时没有加密所需的秘钥 所以 我们 需要生成密码 ssh-keygen -t

【git基础】Permission denied (publickey). fatal: Could not read from remote repository

运行以下git命令的时候出现错误 git push -u origin master error The authenticity of host 'github.com (13.250.177.223)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes

【ASK】git使用中出现Permission denied (publickey).

好久没有用git了,今天突然执行了一下 $git submodule update --init --recursive =============================== 结果出现如下提示 Cloning into 'Submodules/********'... Permission denied (publickey). =============================== 由于确实好长时间没有摸过git了,一点印象都没有了.没办法,只能google了,还好一搜就得到

My solution for Git Client Error: Permission denied (publickey)

在使用Git客户端的过程中遇到的问题以及解决方案分享. 我之前已经安装Git客户端并且使用Git开发过公司项目,也已经正确生成PublicKey并且添加到SSH keys on github of my account,但是当我想从github上克隆另一个客户端push的代码的时候一直报错: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have

github后台上传了ssh公钥之后git clone依然Permission denied

是known_hosts 文件里的公钥信息过期导致的 在/root/.ssh/known_hosts 文件里面将原来的公钥信息删除 重新git clone xxx   yes回车. 大功告成! 原文地址:https://www.cnblogs.com/icefish527/p/12040387.html

git clone gi[email protected]:xxx.git Permission denied (publickey) 问题解决办法

本文主要解决一个问题 git clone 出现公共密钥的权限问题.症状如下: CasondeMacBook-Pro:devops cason$ git clone [email protected]:360yyou/yyou.gitCloning into 'yyou'...Permission denied (publickey).fatal: Could not read from remote repository. Please make sure you have the correc