I would like to allow git to run 'git pull' as user 'www-data'. As far as i understand
git ALL=(www-data) git pull
in /etc/sudoers should make it.
Sadly i get an Syntax error for this line and visudo Syntax highlight breaks right after the "-" in 'www-data'
Can't find information regarding forbidden '-' in /etc/sudoers usernames. Any tips?
You need to use full path name for 'git' command, following lines doesn't produce syntax error in visudo and works fine.
git ALL = (www-data) /usr/bin/git pull
Notice that I'm using git username, so, if you are using gitosis or any other username, just fill in your's!
In console with root user execute this command:
The "vi" editor will be opened. Add these lines:
In result the file (that is opened in "vi" editor by calling "visudo") should look like this:
Then press CTRL+O to save the file, then press Enter to accept the filename (bla bla bla), then press CTRL+X to close the "vi" editor.
Voila! Now git user can execute commands as www-data user: