Permission Denied when pulling into git Repository - linux

I seem to have permissions issue with a git repository.
I git this error when I pull in a directory my Linux user did not create.
fatal: Unable to create '/home/---/.git/ORIG_HEAD.lock': Permission denied
My user is a member of a group called grp. I changed every file to grp:grp and I still cannot pull.
Is there any thought on why this happens? For what it's worth I changed the actual /git/REPOSITORY files also to grp:grp.
Of course, when I use sudo I can pull fine but I prefer not to do it this way.

User: root
1) rm -f ./git/ORIG_HEAD.lock
2) chown -R MY_USER_NAME ./git*
3) chgrp -R MY_USER_NAME ./git*
4) git pull

Related

authorized_keys ignored for new git user

I want to create an own git server. I started with a root user and here is the following I did:
mkdir /srv/git/project.git
useradd -r -d /srv/git git
passwd git
Now I have a new user git (can log in via su git from my root account).
I want to login via git#mywebsite.com without the use of a password. Right now, it will ask for a password every time.
For root, I have my SSH public key in .ssh/authorized_keys. The key should also work for git. Do I have to add another authorized_keys file for this git user? With my useradd command, I do not create a home directory where I could add it, so where should it go?
Thank you all for your help!
Run sudo tail -f /var/log/auth.log and attempt to login once more from a different console. You will see now the lag that should tell you why exactly the login was denied.
In my case there were wrong permissions for the home folder.
You did create a home directory, it just isn't sitting under /home.
/srv/git
Under that directory create a .ssh directory, fix the permissions:
mkdir /srv/git/.ssh
chmod 0700 /srv/git/.ssh
Create a new authorized_keys file with the public key in it, fix the permissions:
vim /srv/git/.ssh/authorized_keys # or method of your choice
chmod 0600 /srv/git/.ssh/authorized_keys

Failed to archieve Gitolite (Git) and nginx webserver access webspace at the same time

Starting point:
Ubuntu 20.04
Gitolite (/home/git/)
Webspace /var/www/webspace (usually owned by www-data:www-data)
Git user (in www-data group and also tried without beeing in group)
I want to update the webspace as git user with post-receive to a www-data directory. I had it archived before I installed Gitolite, but it doesn't seem to work the same way as it did before (or I am missing something). To make it clear: post-receive is executed after pushing (which it's normally not on Gitolite) ... was a hard time too to archive that.
Edit: To make it clear: I want to archive that Git and www-data can access and modify the same files.
What Ive tried:
chmod 777 -R /var/www/webspace (after this git can access but nginx returns with 403?)
Adding Git-User to www-data group
chown www-data:git -R /var/www/webspace
chown git:www-data -R /var/www/webspace
chown git:git -R /var/www/webspace
chown www-data:www-data -R /var/www/webspace (with and without git inside group)(with and without 777)
Executing post-receive manually (Operation not permitted)
Executing post-receive manually as root (well ... works of course, but thats not the point)
... maybe also some steps more which Im maybe missing rn
What Ive noticed so far:
On the contrary to Git, Gitolite checks the repo out with -rw------ (If i remember correctly), maybe that is why its not working with gitolite but with Git
The code (not that it would be important, but just to list everything):
post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/webspace git checkout -f
Maybe Im just missing something, but please help me.
Try and follow "adding other (non-update) hooks" in order for Gitolite to call the relevant post-receive hook.
add this line in the rc file, within the %RC block, if it's not already present, or uncomment it if it's already present and commented out:
LOCAL_CODE => "$ENV{HOME}/local",
put your hooks into that directory, in a sub-sub-directory called "hooks/common":
# log on to gitolite hosting user on the server, then:
cd $HOME
mkdir -p local/hooks/common
cp your-post-receive-hook local/hooks/common/post-receive
chmod +x local/hooks/common/post-receive
run gitolite setup to have the hooks propagate to existing repos (repos created after this will get them anyway).
Add user (git in my case) to group of webspace (www-data for me)
sudo usermod -a -G www-data git
If you were logged in as user logout to reload the group.
logout
#or
exit
#or
CTRL+A+D
(If you want to recheck the group login as this user and type "groups" to see the groups the user is in)
Make sure the webspace is owned by the correct group. For me:
sudo chown www-data:www-data -R /var/www/webspace
(If you want to recheck this you can go in the directory and type "ls -g")
In my case I had to modify my "post-receive" a bit, because the permissions were always -rw----- after checking out, so here is my "post-receive":
#!/bin/sh
GIT_WORK_TREE=/var/www/webspace git checkout -f #default line to checkout
chmod -R a+r /var/www/webspace #added by me because of permission issues
For convenience I had my "post-receive" in the repo directory (/home/git/repositories/repo/hooks/post-receive). The docs tell you to create a new folder (/home/git/local/specific-hooks/repo/post-receive (but they tell to name it on your own))
*All paths, names, groups and permissions written above only apply to me. They may differ for you installation.
What really solved my problem:
Logout after you change groups
Change permission (chmod) in post-receive

Permission denied while cloning project in htdocs

I am new to linux and I am trying to clone a project into a folder that am currently in contained in opt/lampp/htdocs using the command git clone git#gitlab.com:whatever . but i am getting a permission denied error. What can i do to resolve this issue
update httpd.conf
sudo gedit /opt/lampp/etc/httpd.conf
Find
User nobody
Group nogroup
Replace nobody with your username
Change the ownership of htdocs
sudo chown -R username:username /opt/lampp/htdocs
Change the file permissions of htdocs folder
sudo chmod -R 775 /opt/lampp/htdocs/
Restart your machine
Clear your browser cache
You can also give the folder full permissions like this:
sudo chmod -R 777 /opt/lampp/htdocs/
or sudo chown -R $USER:$USER /opt/lampp/htdocs
I already have my username correctly wrote in user in the httpd.conf file, and still had the same problem. Finally, I found the solution changing the port number:
In the same file look for Local:8888 and change 8888 to 80
try to give full permission to your htdocs folder
sudo chmod 777 opt/lampp/htdocs
Then it will ask for password enter and go ahead. learn More Here :)
Permission denied is exactly what it says. You do not have permission to write to this folder. You can either git clone the repo as a root using sudo git clone (...) or change permissions to this folder. sudo chmod a+w <path> and then git clone it normally. You can also clone the repository to some other folder to which you already have permissions to write to.

SVN post-commit update error (Can't create temporary file from template / permission denied)

My post-commit hook is:
/usr/bin/svn update /var/www/html/mysite/ --username myusername --password mypassword --no-auth-cache >> /var/www/html/mysite/foo.txt 2>&1
After performing a commit, my post-commit hook outputs to foo.txt the following:
Updating '/var/www/html/mysite':
svn: E000013: Can't create temporary file from template '/var/www/html/mysite/.svn/tmp/svn-XXXXXX': Permission denied
Any ideas?? Must be something related to permissions. It used to work, but something happened.
check if you have the permission of /var/www/html/mysite/
When this happens to me (svn 1.7.14), I usually just have to create the tmp directory and retry the command:
mkdir /var/www/html/mysite/.svn/tmp
For all Linux Machine Users
Its file permission issue run this particular command in linux terminal.
chmod -R 0777 /var/www/YourProjectName

How to allow a group access for a GIT repo (Ubuntu)

So I have a GIT repo hosted with Gitosis.
I have a user called user1 and of course user root.
user1 belongs to group 'dev'
/var/www is owned by root, and grouped to 'dev'
permissions for the group are rwx
user1 has confirmed access to the git repo. I cloned it already and that works fine.
BUT, when I try to have user1 pull the repo on /var/www I get
error: cannot open .git/FETCH_HEAD: Permission denied
So what else am I missing. The GIT repo is already a --shared repo. For some reason I can't get this user to pull on /var/www ?
Thanks!
So turns out the answer was to change the GROUP of the .git folder to that of the user.
I hadn't realized that .git/FETCH_HEAD was a program and access was denied to run that. I thought it was a gitosis thing but it wasn't.
Thanks!
You can fix them retroactively (after which you won't need the config setting) with
chmod -R user:group /path/to/shared.git
find /path/to/shared.git -type d |xargs chmod 2775 # or 2770 if you don't want it public
find /path/to/shared.git -type f |xargs chmod 444 # or 440
find /path/to/shared.git/hooks |xargs chmod ugo+x # or ug+x

Resources