GitHub:权限被拒绝(公钥).致命:远端意外挂断 [英] GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly
问题描述
我已按照以下说明上传项目.
I have followed these instructions below to upload a project.
全局设置:
Download and install Git
git config --global user.name "Your Name"
git config --global user.email tirenga@gmail.com
Add your public key
Next steps:
mkdir tirengarfio
cd tirengarfio
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:tirenga/tirenga.git
git push origin master
但我收到此错误:
权限被拒绝(公钥).致命的:远端意外挂断
Permission denied (publickey). fatal: The remote end hung up unexpectedly
推荐答案
对我来说,问题是通过 sudo 执行克隆.
For me the problem was the execution of clone via sudo.
如果您克隆到您拥有用户权限的目录 (/home/user/git),它将正常工作.
If you clone to a directory where you have user permission ( /home/user/git) it will work fine.
(解释:以超级用户身份运行命令不会使用与以用户身份运行命令相同的公钥.因此 Github 拒绝连接.)
(Explanation: Running a command as superuser will not work with the same public key as running a command as user. Therefore Github refused the connection.)
此解决方案需要已设置 SSH 密钥:https://help.github.com/articles/generate-ssh-keys
This solution requires a SSH key already to be set up: https://help.github.com/articles/generating-ssh-keys
这篇关于GitHub:权限被拒绝(公钥).致命:远端意外挂断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!