拉取gitHub新建仓库时,公钥存到非默认目录的操作

1、打开git命令行控制台,执行:

ssh-keygen -t rsa -C "123456@qq.com"

 

2、执行到:

Enter file in which to save the key (/c/Users/Lang/.ssh/id_rsa):

输入你想存放的目录,例如:/E/Project/gitTest/.ssh/id_rsa

再继续三次Enter后,去此目录:

ec /E/Project/gitTest/.ssh/

 

3、查看公钥:

cat ./id_rsa.pub

复制公钥粘贴到gitHub,SSH keys / Add new输入框,进行提交

 

4、拉取仓库:

 git clone git@github.com:YourProject/test.git

发现有报错:

Cloning into 'VideoScreenshot'...
Warning: Permanently added the RSA host key for IP address '1xxxxxxx23' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

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

 

5、这是因为没有把专用密钥添加到ssh-agent的高速缓存中

于是执行添加命令:

ssh-add /E/Project/gitTest/.ssh/id_rsa

 

6、若执行ssh-add /E/Project/gitTest/.ssh/id_rsa 时出现以下错误:

Could not open a connection to your authentication agent

则先执行如下命令启动ssh代理:

ssh-agent bash

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Longsir_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值