/bin/cp: cannot create regular file: Permission denied
So I'm following a deployment config file for cPanel and I think I'm pretty close to getting it set up. Part of the deployment process is to run the command on
line 4
:
The deployment process wasn't completing, so I logged into my git
user (the one that owns the home directory, not the root
user). I tried running the command /bin/cp index.html $DEPLOYPATH
and I get the following error:
I've poked around and this seems to be a permissions issue. On further inspection, it seems to be the /home
directory. The git
user isn't authorized to read the /home
directory (though I am able to execute /bin/cp
and cd
into /home/git
(git
's ~
directory)). I believe it would fix the issue if I changed the permissions, but the thing is, I don't want to. It doesn't make sense for me to do that either -- I don't want my git
user to have access to other users' folders / files. Am I missing something or is the only way to sudo
or change the /home
folder permissions?36 Replies
What does
ls -ld /home/git /home/git/public_html
show?
Both should be owned by git
and user writable.Hey, thank you for the response! I get the following output from that command:
Admittedly, I'm pretty bad at these commands so I'm not sure that they're writable. I think they're owned by
git
by the 3rd column and I do see the w
for writable in the first column but I'm not sure if that's writable for git
or for root
So I just set rwx
permissions to the group as well and I still get the error. So the git
owner and git
group both have rwx
:
Lol I figured it out, thank you for rubber ducky-ing
For whatever reason index.html
was owned by root
, so I chown git index.html
as the root
user and that worked!
I've learned so much about linux commands doing this
Though I still don't like how I have to give the /home
directory's others
group execute permissions for it to work
I feel like that could be a security issue...i hope i am not late but ... why do you have the public_html folder in an home directory?
It's under a user
i know, but why?
that's how cPanel sets it up by default
user-based
public_html
folders aren't that strange, lots of apache setups support themyes, but it isnt common on local development environments
therefore the question
fair enough
i do like how cpanel/whm does it
a user per website
I think it makes a lot of sense but I don't know anything else
I can just do
sudo -iu <user>
in the cmd line and do whatever I need on that websiteinteractive sudo as the user?
yea it just lets me log in as the user and i go straight to their home directory
so i dont have to go
cd /home/<user>
I can just do sudo -iu <user>
then cd public_html
then git pull origin main
that is very smart, but can be automated
Yup which is what this thread is for 😂
I have it so I can just click 2 buttons in cPanel to have it pull from GitHub and then push to staging, but I still need to automate the pull step with GitHub actions
if you have docker, in the server, you can use it as a runner
we use ddev which I know uses docker under the hood but I think we're just exposing the built web/ files
as long as you can do something with the docker, it's fine
Yea I don't think we're using docker to host it or anything
It's an apache server that just looks for the web dir I think
that's how cpanel works
so how would adding anything to docker help automate the process if what I'm trying to do is automatically pull changes from github and then build and push to staging on the server?
you use docker to host github runners
and then, the actions run in your server
making things a lot easier for you
oh you're saying to self host the runners via docker ?
I was just going to let github do it
I want lowest barrier to entry as possible I'm not trying to overcomplicate it since I don't know how docker works
well, you have a server that you're already paying for
and if it is doing the runner's job, then everything is "right there"
you can have both too, and your server works as a fallback
yea that would make the most sense to self host it but idk what im doing and im not getting paid for this so trying to keep it as simple as possible
idek how to automate the pulling yet via github actions
then try it for yourself first
i know theres preconfigured ftp actions but they kinda look like junk
so im just gonna make a custom one
ssh is an option
yea thats what i was looking at
it seems like i just have make a few steps for the github runner:
on
staging
branch push:
1. log into ssh and into the right user
2. pull staging branch from github
3. cp
git repo into staging directory
does that sound right? I dont have to build anything as we're just pushing the already built files into the git repohere's the problem: you will have to connect to ssh multiple times, as ssh doesn't give you any information on if a command is running or not
o really? huh
its not smart enough to create a session with the runner?
it's not that
it's just that you would need a screen reader to run more than 1 command in ssh, automatically
you would need things like expect
so, you will connect to ssh once per command
and there's a tiny chance that one of the ssh commands doesn't connect, or takes too long
i c
one step closer
i didn't have to do any multiple ssh stuff
though i did use a third party action
as long as it works, that's the most important