使用git push origin master向github推送代码,出现[email protected]: Permission denied (publickey).

今天的任务是把项目通过git上传到github仓库内,于是出现了[email protected]: Permission denied (publickey)这个问题,现在我把解决方案分享给大家。

问题

初始化项目仓库,推送代码到实现创建好的代码库上。

# cd /Users/jackyue/python/2

# git init

# git add aimarket.pptx

# git commit -m "ppt commit"

# git remote add origin [email protected]:locutus666/2.git

# git push -u origin master

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

报错[email protected]: Permission denied (publickey).


解决

查看调试信息

# ssh -v [email protected] 

查看~/.ssh/id_rsa.pub文件

more ~/.ssh/id_rsa.pub

把本机ssh-key拷贝到你github网站的ssh key里,在github的右上角edit your profile 里找到ssh key,然后add ssh key,把东西拷贝到key就可以了,title随便填。
使用git push origin master向github推送代码,出现git@github.com: Permission denied (publickey)._第1张图片

使用git push origin master向github推送代码,出现git@github.com: Permission denied (publickey)._第2张图片

使用git push origin master向github推送代码,出现git@github.com: Permission denied (publickey)._第3张图片

在这里插入图片描述

你可能感兴趣的:(git)