1

Disclaimer: I know this question has been asked a lot, i've read a bunch of ways and tried a bunch of ways, but i'm still running into issues, please feel free to refer me to a dupe question if you think it helps.

I have a ubuntu server, and currently use my own user invisibled and not root. I login to the server with this user and can sudo with this user, but I have to sudo to make any changes to any files, which includes running git pull. I want to be able to add/edit/delete files in the /var/www/ folder without having to sudo and type my password. The password prompt specifically is what I want to rid of as it gets in the way of remotely executing git pull requests.

Can I do something as simple as giving my user full authority over the /var/www/ folder? Everything in here is in a git repo and can be wiped out if need be.

I'm a web developer by profession and my ubuntu knowledge is just self taught to be able to manage these servers, so i'm not sure what the best, or correct approach is. Any info/tips would be amazing! Let me know if you need any more info.

EDIT:

Typing groups shows invisibled www-data so my user is part of the www-data group.

The /var/www/ folder's ownership permissions:

drwxrwsr-x  10 root       www-data   4096 Sep  8 15:23 .
  • 1
    Any reason you can't change the ownership of /var/www and everything in it to your account? – Cry Havok Sep 8 '15 at 21:06
  • other than the fact that I have tried to do that and it didn't seem to do anything... Do you have a solid way of doing that? I think the "groups" part trips me up... i'm not sure what group to assign it to. – Shan Robertson Sep 8 '15 at 21:07
  • 1
    @ShanRobertson: That question from your comment is difficult to answer without further details. What are the current permissions? What did you try to change about them and how? What was the result? Maybe you can elaborate in an edit your question or in a new question. – David Foerster Sep 8 '15 at 21:09
  • ok, i've edited with the group and ownership permissions on the folder. I can't honestly remember what i tried for ownership on the folder, but i've added my user to www-data. Does this help? – Shan Robertson Sep 8 '15 at 21:16
  • But git pull and push will still ask you for the password right – Kenpachi Sep 8 '15 at 21:55
1

Try this,

less /etc/group

You should see your user name in front of group www-data. Something like this,

www-data:x: ................. <your-user-name>

If this isn't the case, add yourself to the group,

sudo gpasswd -a <your-user-name> www-data

If your name was already there, then it means files inside /var/www don't belong to this group. In that case, just change their group using chown command,

sudo chown :www-data -R /var/www/

You'll have to logout and login for all group related changes to take effect.

0

You can add a file to the /etc/sudoers.d directory using your fav text editor (vi, nano, ...). The file name is arbitrary (any name will do, e.g., "addmyuserid"). File content is fixed and spaces (whitespace elements) are required as shown:

<myuid> ALL=(ALL:ALL) NOPASSWD: ALL

Once the file is written to the /etc/sudoers.d/ directory, restart Ubuntu, and after logging in, you should be able to enter sudo ... commands without required pw entry after the first one, and then every 5 minutes or so (the sudoers timeout interval is also changeable if you wish to get into it).

Note: this file addition allows full root control via sudo to anyone who signs into your Ubuntu server with your ID; so be careful and make sure to protect your PW or other sign in credentials. If your server will be used for general web access, you may want to remove the added file from the /etc/sudoers.d directory before launching the server for production use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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