Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  16] [ 0]  / answers: 1 / hits: 51472  / 1 Year ago, wed, march 15, 2023, 9:01:27

I created a directory /var/www to store my web apps clone in. When I initially cloned the app from GitHub it required me to use sudo and every time I do a git pull it's requiring sudo. I'm running into some problems because of this. For example, my ssh keys are not matching up. So when I do my git pull, I'm having to use HTTPS instead of ssh and manually enter my username and password every time I want to pull and update my app. How do I configure this so I don't have to use sudo every time I use git?


More From » ssh

 Answers
0

A couple of things are going on here:




  • When you sudo git checkout ..., all those files are owned by the root user and root group. With the standard permissions, that's why subsequent alterations to those files require you be root.


  • /var/www/ by default is owned by www-data group. Something your user is not by default.




The easiest way to write in /var/www/ is to just add your user to the www-data group. You can of course, change the directory to be owned by your user but this can have some nasty knock-on effects if you're not pre-empting them.



You'll need to re-log in after adding your user to the www-data group.



In your case specifically, you're going to need to fix your current mess of root-owned data. You can either delete it as root (and re-checkout) but if you have unsaved work, it'll just be cleaner to pull everything back to your user. The following example is extremely lazy and assumes what we're talking about is the only thing in /var/www/:



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

[#29525] Friday, March 17, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
quivedge

Total Points: 223
Total Questions: 116
Total Answers: 124

Location: Slovenia
Member since Wed, Apr 6, 2022
2 Years ago
;