I always get permission denied after git pull

Need help please for the permission I was deploying our webapplication to new server, my problem is that everytime I will git pull in root user, when I check my webapplication I get permission denied always. Like for example I will edit the UserController and push to repo and download to my server using git pull. when I visit to Users route I get permission denied.

can you help me please to set up correctly the permission framework I used is Laravel

Ubuntu 20.4

Then I will execute this command so that the permissioned denied will be gone

sudo find /path/to/your/laravel-directory -type f -exec chmod 644 {} \;
sudo find /path/to/your/laravel-directory -type d -exec chmod 755 {} \;

Don’t pull as user root, pull as user www-data.

1 Like

check the premmisions setting?

If i will login using ssh user , this will show on terminal webdev@ip-xxx-xxx-xxx not www-data. now if I will git pull I will get permission denied, that’s why I will sudo su so that I can pull.

image

this is not logged as root

image

I change the owner of files and direttories , but after I git pull, and visits my browswer and access the route I edited will show permission denied.

Okay, so you can run sudo -u www-data to become user www-data.
You still won’t be able to do git pull then though, so you should copy the private key from root to www-data as well.

sudo -s
cp /root/.ssh/id_rsa /home/www-data/.ssh/
chown www-data: home/www-data/.ssh/

That should copy the private key from root to www-data and move ownership to www-data so the key can be read when logged in as www-data.

Hi, I don’t know what is missing I cannot execute. this is result of my teminal

No www-data found here only my ssh username
image

image

You havent given it a command.

says “become root and run find …”

sudo -u www-data says “become www-data and”

You havent told it what to do (hence sudo) once it becomes www-data.

I followed this instruction

https://linuxhint.com/how-to-set-up-file-permissions-for-laravel/

Ah right, by bad. What I meant was sudo su - www-data to switch to user www-data.

HI

image

Yeah ok. This isn’t working.

I’m not your terminal, you’ve got at least try something for yourself.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.