Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I’m trying to set up a workflow where my code base is version-controlled under Git, and then deployed to a live server over SSH.

I wrote a simple shell script that I run from my machine that opens an SSH connection and then executes git pull on the remote server. However, because this is being ran under root (don’t ask) all files and folders that are then created/updated by Git are given the user/group of root too, instead of apache.

How do re-assign apache as the user/group of these files/folders? Do I need to alter my workflow, or could I just run chown and chgrp after I’ve pulled from Git? Ideally, I’d like to just fix where I’d rather treat the problem though rather than treating the symptoms.

share|improve this question

1 Answer 1

You'ld better use another user than root. Anyway, use su -c or sudo to run git pull with the correct username

share|improve this answer
    
I know, but it’s a client’s server and that’s the only login they’ve given me. How do I use su -c/sudo to run git pull as apache? –  Martin Bean Jan 17 '13 at 10:30
    
They gave you root access, so in effect it is NOT the only login the gave you. They gave you the keys to the kingdom. So now you can set it up correctly. –  vgoff Jan 17 '13 at 11:15
    
So what is the correct steps to get Git to pull on the remote server, but not then assign everything it does the user/group of root? –  Martin Bean Jan 17 '13 at 11:16
    
You might look at this setup. serverfault.com/a/234442/144062 –  vgoff Jan 17 '13 at 11:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.