git push时提示The authenticity of host 'github.com (52.74.223.119)' can't be established.

问题现象:

github上创建了一个远程仓库,将我的代码推送到远程仓库git push -u origin master时,出现下面报错

 

The authenticity of host 'github.com (52.74.223.119)' can't be established.

RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.

git@github.com: Permission denied (publickey).

fatal: Could not read from remote repository.

问题原因:Github与ssh连接需要密钥

解决方法:

1.本地mac 公钥路径取密钥:cd ~/.ssh  (id_rsa.pub

2. 登录自己的github进入项目的存储库----进入setting----部署秘钥(Deploy keys)

3.配置ssh key的时候勾选下面的Allow write access,在settings的deploy key栏目才有读写权限

4.配置完成之后再去项目中操作git即可

解决结果:

git push -u origin master

Enumerating objects: 3, done.

Counting objects: 100% (3/3), done.

Writing objects: 100% (3/3), 218 bytes | 109.00 KiB/s, done.

Total 3 (delta 0), reused 0 (delta 0)

To git+ssh://github.com/illusion1010/Hog.git

 * [new branch]      master -> master

Branch 'master' set up to track remote branch 'master' from 'origin'.

原文地址:https://www.cnblogs.com/illusion1010/p/11667069.html