I have been following these directions when it comes to installing Git onto my Ubuntu 14.4 machine and followed the GitHub directions on how to obtain and save an ssh key pairing.
Right now I am trying to commit to the remote Github location by doing the following:
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'.
It seems it's unable to access my GitHub location. To verify, I did the same command as mentioned only sudo git push origin master
and got the following error Permission denied (publickey)
.
In order to give more background, I created my ssh key in the following way:
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'.
As seen by when I copied the ssh key with xcut, I pasted the key into the SSH Key section of my account on GitHub.
I have also tried to look at the following questions on the forum
https://askubuntu.com/questions/137165/git-ssh-permission-denied-publickey
https://askubuntu.com/questions/267392/using-authorized-keys-with-git
EDIT: I tried to see if the error was occurring locally by granting read/write permission to the user beckah
through opening the folder and using chown -R beckah .
and then trying to grant read/write access to the folder for all users with chmod 777 -R testing/
. Both of them still rendered permission errors when I tried to commit to the project after.
/git/hosting
. Then in that directory issue the commandsudo chown -R beckah .
It appears from the output your account isbeckah
. Then try your git push again. I think this is a local permission problem (not a remote one) – Michael Petch Sep 4 '14 at 19:57