当我们拿到一天别人用的电脑,里面是上一位前辈的git ssh key,这时候我们要自己改,改完之后上传代码到远程repository时,

可能会报git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

 git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

 

解决方案:

删除当前key,然后重新生成key:

$ ssh-keygen -t rsa -C "你的GitHub注册邮箱"

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

 

将本机生成的ssh key复制到个人GitHub账户中去。

本机账户文件夹下找到id_rsa.pub,以text方式打开,复制内容。git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

 

打开GitHub,登陆个人账户,添加ssh key

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

 

 再去执行:

$ git push -u origin master

完美上传。

 

相关文章: