1

I have setup Git on our production and staging server and it's working well, however upon doing a git pull on the staging server it seemed to set the group owner name to the user I was logged into under SSH, which was root.

Is there anyway to get it to set the group name to another name without having to log in as that particular user?

Brett
  • 19,449
  • 54
  • 157
  • 290

2 Answers2

2

You can add under root keys for the desired user's.

Since the authentication is done via ssh you cannot "fake" it to be different user. (assuming you are not trying to hack the system).

That's the point of using SSH - to verify the one who initiated the action.


Referring to the above answer suggesting to execute a chmod:

If you will do a chmod it can be tracked as change as well if you have set mode flag.

git config core.fileMode false

core.fileMode
If false, the executable bit differences between the index and the working copy are ignored; useful on broken filesystems like FAT.
True by default.


git ssh

Read more about how it works here

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • Can you explain a bit more what you mean by "You can add under root keys for the desired user"? – Brett Mar 15 '16 at 16:32
  • Yep. right now you are using the ssh keys under your root account - which cause the server to authenticate you as root user. use different keys (from different users do the server will recognize you as the new user – CodeWizard Mar 15 '16 at 16:38
0

I see two solutions:

  1. Execute the command as the process user (which is the most reasonable change). Something like su theprocessuser -s /bin/bash -c 'cd /some/dir && git pull
  2. Execute chown after your "git pull" and embed everything inside a deploy script

In a more general way, you should have a look at Ansible, Fabric or similar useful tools. In a more general way, you should definitely not use the root user for operational tasks.

SamK
  • 2,094
  • 3
  • 17
  • 18