Reputation: 3415
UPDATE (11/4): Just to test to see if it was indeed a permission issue on my linux box,
I'm getting a 'insufficient permission...' error when trying to push to my bare repo on my linux AWS server.
$ git push origin master
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 622 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: error: insufficient permission for adding an object to repository database objects
remote: fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To awsDev:/AWSbareRepo
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'awsDev:/AWSbareRepo'
I can pull, but not push. I've done a 'git ls-remote' and it comes back fine with the available references in the remote repository along with the associated commit IDs, so connectivity is not the issue.
I've also set the core.sharedRepository to true in the .config file:
[core]
repositoryformatversion = 0
filemode = true
bare = true
sharedRepository = true
~
~
~
On my AWS linux server on the bare repo directory I do a 'ls -la' and I receive the following:
$ ls -la
total 40
drwxr-xr-x 7 root root 4096 Nov 4 04:56 .
dr-xr-xr-x 28 root root 4096 Oct 14 02:06 ..
drwxrwsr-x 2 root root 4096 Apr 16 2015 branches
-rwxrwSr-- 1 root root 91 Nov 4 04:56 config
-rw-rwSr-- 1 root root 73 Apr 16 2015 description
-rw-rwSr-- 1 root root 23 Apr 16 2015 HEAD
drwxrwsr-x 2 root root 4096 Apr 16 2015 hooks
drwxrwsr-x 2 root root 4096 Apr 16 2015 info
drwxrwsr-x 12 root root 4096 Oct 14 03:21 objects
drwxrwsr-x 4 root root 4096 Apr 16 2015 refs
I've ssh'd into my server and tried reading over Git Push Error: insufficient.. question, but not sure what group I need to give permission to? Do I need to add a new group on my AWS server that matches the group on my dev box?
Additional info: In case I wasn't clear, I'm attempting a 'git push origin master' from my local dev box to a AWS linux server. The push is from my local DEV box and when I try to push I am not SSH'd into my AWS Linux box.
Not sure if this is neccesary, but my AWS Linux server has IP rules, which prevent any SSH connectivity that does not originate from my IP address.
Upvotes: 2
Views: 686
Reputation: 3415
On my local repo (dev box) I did a vim ~/.ssh/config
which returned:
Host awsDev
HostName ec2-01-23-45-678.us-west-2.compute.amazonaws.com
User ec2-user
IdentityFile /Users/MyName/Desktop/AWSFolder/MyAWSPemKey.pem
~
~
~
From the local repo (Dev box) I did a $ git remote -v
which returned:
origin awsDev:/AWSbareRepo (fetch)
origin awsDev:/AWSbareRepo (push)
At this point I realized I was connecting with 'ec2-user' and I had already pointed ssh to my .pem key and I could resolve my permission issue by simply changing the file owner of the entire bare repo (on my AWS Linux box) from 'root' to 'ec2-user'.
On my AWS Linux box in the bare repo directory did a $ chown -R ec2-user .
then verified by doing a $ ls -la
that the file owner did indeed change from 'root' to 'ec2-user'.
My next step was to update the permission for the bare repo so I did a
chmod -R 770
which changed my permission so the owner and users in the root group can read,write, and execute, but all others can't. I could have done 700, because ec2-user is the owner.
I once again did a $ls -la and verified permissions were correct.
After all this I was able to push and pull to my bare repo from both my local repo on y DEV box and from the repo in the AWS Linux box.
BTW: Nice little Linux permission calculator.
Upvotes: 1
Reputation: 38207
(This answer is assuming you are using ssh+git to connect to the repository.)
Try typing id
when you are logged into AWS per ssh. This will give you the user id of the user you log in as. When you have found that out, change the repository's permissions via (inside the repository)
chown -R user_id:user_id .
This will change ownership of all files in the repository to the user you log in as. (the :user_id
changes group ownership as well)
Explanation: Your repository is owned by root
. Unless you also log in as root
, you will not have write permission.
Upvotes: 2