【发布时间】:2014-10-29 16:08:41
【问题描述】:
在将 Git 安装到我的 Ubuntu 14.4 机器上时,我一直遵循 these 的指导,并遵循 GitHub directions 的有关如何获取和保存 ssh 密钥配对的指导。
现在我正在尝试通过执行以下操作来提交到远程 Github 位置:
beckah@the-tank:/git/testing$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 208 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:rsheeler/Ubuntu_Test.git
* [new branch] master -> master
error: unable to create directory for .git/refs/remotes/origin/master
error: Cannot lock the ref 'refs/remotes/origin/master'.
它似乎无法访问我的 GitHub 位置。为了验证,我执行了与仅提到sudo git push origin master 相同的命令,并得到以下错误Permission denied (publickey)。
为了提供更多背景知识,我通过以下方式创建了我的 ssh 密钥:
beckah@the-tank:/git/testing$ ssh-keygen -t rsa -C "rebeccasheeler@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/account/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/account/.ssh/id_rsa.
Your public key has been saved in /home/account/.ssh/id_rsa.pub.
The key fingerprint is:
##:##:##:##:##:##:##:##:##:##:##:##:##:##:##:## rebeccasheeler@gmail.com
The key's randomart image is:
{little image here}
beckah@the-tank:/git/testing$ eval "$(ssh-agent -s)"
Agent pid 30342
beckah@the-tank:/git/testing$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/beckah/.ssh/id_rsa:
Identity added: /home/beckah/.ssh/id_rsa (/home/beckah/.ssh/id_rsa)
beckah@the-tank:/git/testing$ sudo apt-get install xclip
[sudo] password for beckah:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
xclip
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 16.5 kB of archives.
After this operation, 67.6 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/universe xclip i386 0.12+svn84-4 [16.5 kB]
Fetched 16.5 kB in 0s (113 kB/s)
Selecting previously unselected package xclip.
(Reading database ... 194616 files and directories currently installed.)
Preparing to unpack .../xclip_0.12+svn84-4_i386.deb ...
Unpacking xclip (0.12+svn84-4) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up xclip (0.12+svn84-4) ...
beckah@the-tank:/git/testing$ xclip -sel clip < ~/.ssh/id_rsa.pub
beckah@the-tank:/git/testing$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
Hi rsheeler! You've successfully authenticated, but GitHub does not provide shell access.
beckah@the-tank:/git/testing$ sudo git push origin master
Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
beckah@the-tank:/git/testing$ git remote add origin git@github.com:rsheeler/Ubuntu_Test.git
fatal: remote origin already exists.
beckah@the-tank:/git/testing$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 208 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:rsheeler/Ubuntu_Test.git
* [new branch] master -> master
error: unable to create directory for .git/refs/remotes/origin/master
error: Cannot lock the ref 'refs/remotes/origin/master'.
当我使用 xcut 复制 ssh 密钥时可以看到,我将密钥粘贴到了我在 GitHub 上帐户的 SSH 密钥 部分。
我也试过在论坛上看以下问题
https://askubuntu.com/questions/137165/git-ssh-permission-denied-publickey
https://askubuntu.com/questions/267392/using-authorized-keys-with-git
编辑:我试图通过打开文件夹并使用chown -R beckah . 向用户beckah 授予读/写权限然后尝试授予读/写权限来查看错误是否在本地发生具有chmod 777 -R testing/ 的所有用户对该文件夹的写入权限。之后我尝试提交该项目时,它们仍然出现权限错误。
【问题讨论】:
-
进入你的本地源目录,我猜是
/git/hosting。然后在该目录中发出命令sudo chown -R beckah .从输出中显示您的帐户是beckah。然后再次尝试您的 git push。我认为这是一个本地权限问题(不是远程问题)
标签: linux git github ssh permissions