关于git合并代码到github时报错的问题
https://help.github.com/articles/error-permission-denied-publickey/
官网给出有几个原因,我这里记录的最主要原因是没有生成ssh Keys
那么如何操作呢
第一步打开:git bash 不用进行你的资源库目录,在外面就行
第二步:检查你的目录下面有没有类似下面名称的文件这是是默认密钥名称。如果有说明你已经生成ssh key,就跳过后面生成的步骤
- id_dsa.pub
- id_ecdsa.pub
- id_ed25519.pub
- id_rsa.pub
后面会提示你输入密码
- Enter passphrase (empty for no passphrase): [Type a passphrase]
- # Enter same passphrase again: [Type passphrase again]
- # Your identification has been saved in /Users/you/.ssh/id_rsa.
- # Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
- # The key fingerprint is:
- # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
然后再把新增的key 添加到ssh-agent 命令如下:需要说明的是is_rsa文件在你相应目录下面,你可以用记事本查看的
- # start the ssh-agent in the background
- eval "$(ssh-agent -s)"
- # Agent pid 59566
- ssh-add ~/id_rsa
第五步:测试 ssh -T git@github.com
如果有如下警告
- # The authenticity of host 'github.com (207.97.227.239)' can't be established.
- # RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
- # Are you sure you want to continue connecting (yes/no)?
不要急,直接输入yes回车就行
如果还提示权限没有,就查看你的目录 ssh -v git@github.com 是查看版本信息
说明你的目录有个 .ssh 看你的id_rsa.pub 文件在不在.ssh目录里面,如果不在直接复制过去
最后提示
- # Hi username! You've successfully authenticated, but GitHub does not
- # provide shell access.