permission denied (publickey)问题的解决方法

1、如果第1步中的SSH key不存在,生成一个新的SSH key

先:

cd /Users/your_user_name/.ssh

命令如下:

ssh-keygen -t rsa -b 2048 -C "email@example.com"

其中,`email@example.com`你自己的邮箱地址。

2、回车后输出如下:

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

直接回车,会将key保存到默认文件中。

3、接着会输出:

Enter passphrase (empty for no passphrase): Enter same passphrase again:

4、这个密码在提交git时会用到,一定要记住,最好和登录密码一直

回车后就提示成功了:

Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:c09fnBhwsvjA1gc85IT5DqO8NofpK/NC48y2TN8gZdQ email@example.com

5、到这一步,你会发现 `/Users/your_user_name/.ssh/id_rsa.pub` 文件已经生成了。

6、打开`id_rsa.pub`文件,复制里面的内容,然后粘贴到git中相关的位置中。

7、 把ssh 添加到keychain中

这个时候如果去git clone代码,会让你输入密码,如果一个还好说,如果关联了很多的话,那就比较麻烦了,这个时候的解决方法就是添加到keychain中:

ssh-add -k /Users/youre_user_name/.ssh/id_rsa

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值