文章目录
前言问题分析解决方法配置客户端配置服务端验证前言
在使用goland从github下载依赖时(git clone /gin-gonic/gin)出现git@:Permission denied(publickey).fatal: Could not read form remote repository
错误。
问题分析
Permission denied(publickey):没有权限
说明github和本地git没有生成ssh key或者ssh key不匹配
解决方法
配置客户端
客户端(本文为windows10电脑),打开git bash,执行ssh-keygen -t rsa -C "github登录邮箱"
然后一路回车(不用输入)。在git bash执行ssh -v git@
出现下方文字
No more authentication methods to try.Permission denied(publickey)
如图:在git bash执行ssh-agent -s
,如图
在git bash执行ssh-add ~/.ssh/id_rsa
,如图
出现Could not open a connection to your authentication agent
警告
在git bash执行ssh-agent bash
命令,然后再次执行ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/zhandongyang/.ssh/id_rsa
,这是ssh key文件在windows电脑上的位置,用记事本打开这个路径上的id_rsa.pub
文件,复制里面的内容。
配置服务端
本文的服务端为github,访问github网站、登录,点击右上角的头像,然后点击Settings选择SSH and GPG keys,选择New SSH keyTitle写个自己记得住的名字,Key填写复制的id_rsa.pub文件内容
验证
在客户端(本文为windows10电脑)的git bash执行ssh -T git@
至此结束。