解决git身份验证的问题

换了新电脑,重新配置hexo博客:

1
2
3
npm install hexo-cli -g
npm install hexo --save
npm install hexo-deployer-git --save

然后push代码,报错git@github.com: Permission denied,大意是git没有权限。

打开git bash,解决过程: 1.查看是否已经有了ssh密钥:

1
cd ~/.ssh

2.生成密钥:

1
ssh-keygen -t rsa -C "neptoo57@gmail.com"

按3个回车,密码为空。 3.将本地生成的id_rsa.pub添加到github的新ssh密钥 4.测试

1
ssh git@github.com

提示

1
2
3
PTY allocation request failed on channel 0
Hi neptoo! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

5.配置

1
2
git config --global user.name "example"
git config --global user.email "example@gmail.com"

问题解决,可以使用更新博客了。

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy