Jenkins - copy files to web folder permissions denied - linux

I have added jenkins to the www-data group
jenkins : jenkins www-data
Which owns my html folder
drwxrwxr-x 12 www-data www-data 4096 Sep 4 14:18 html
I try and copy a folder from the build
cp -R resources /var/www/html
but I get the errors
cp: cannot create regular file '/var/www/html/resources/assets/js/app.js': Permission denied
all the files and subfiles are owned by www-data and in the www-data group but I still get the error
cp: cannot create regular file '/var/www/html/resources/assets/js/app.js': Permission denied

Related

chmod 744 to my home dir, other user in same group can still not copy/cd my files

So my home dir is set as:
drwxr--r-- 16 me users 4096 Jan 15 09:17 me
I want to copy my files from using admin user which belongs to the same group(users):
drwxr-xr-x 2 otickadm users 4096 Jan 15 08:59 common
However I can't:
$ cd /jhome/jyun1
-bash: cd: /jhome/jyun1: Permission denied
$ cp /jhome/jyun1/gitworkspace/taq_scripts/sanity_check.py .
cp: cannot stat ‘/jhome/jyun1/gitworkspace/taq_scripts/sanity_check.py’: Permission denied
Wondering if anything else is taking control of this permission.
cd (and read files) requires execute (x) perms on the directory; try 75x to allow others in your group to cd to your directory and/or read your files

Unable to access file directory and files Centos 7

+x Permission is provided for user and directory is owned by the user.
drwxr-xr-x. 3 www-data www-data 19 Nov 30 10:41 www
Still, I am unable to access the directory.
www-data is Nginx and PHP-fpm user. When I try su www-data I can't access any directory inside /var although I can do cd /var.
You can check if this account has a login access, by checking items in /etc/passwd.
If it has a "nologin", you can't login with this us

Grant user write permissions on /var/www/html via www-data group

I've setup a new web server, I have created a user 'webuser', and have added the user to the group 'www-data'. When I try to upload a file via SFTP to /var/www/html I get an Permission Denied error.
So far I've tried;
usermod -aG www-data webuser
chown -R www-data:www-data /var/www/html
chmod -R 775 /var/www/html
None of these have allowed write permission on /var/www/html
The details of the folder are:
drwxrwxr-x 9 www-data www-data 4096 Oct 10 10:00 html

File permission in ubuntu

I have a VPS and use it for hosting my sites. The server is nginx with php-fdm.
my site is in the /var/www/sitename/html/ and all the files and folders under the html directory owned by www-data www-data. All files permision is 664 and directories (html folder and sub-directories) has 775 permission. And also my user is member of the www-data group.
I can change every files in this folder, but I can't make new file or new folder here. This need sudo privileges. I can create new file in the sub-directories like /var/www/sitename/html/uploads but not in the /var/www/sitename/html/ while they have the same owner and permission.
The user you are logging in as is not the www-data user or a member of the www-data group.
I set things up on my servers so that the user I log in as owns the files/directories, and a webuser group is the owning group, perms are set to 750/640. You can automagically keep the owning group the same across all files/directories uploaded to/created on the server by making the top level web directory setgid.
drwxr-s--- 4 debbie www-data 4096 Oct 6 2015 /var/www-debbie.example.com
If the webserver needs to write files, create the directory and change the permissions on it
sudo mkdir /var/www-debbie.example.com/writeable
sudo chmod 770 /var/www-debbie.example.com/writeable
If you haven't done the setgid thing, then fix the ownership
sudo chown debbie.www-data /var/www-debbie.example.com/writeable
And there ya go, the web server user can write to it.
drwxrws--- 4 debbie www-data 4096 Oct 6 2015 /var/www-debbie.example.com/writeable

ec2-user does not has permission to write to web folder

I created an apache web server using CFT; this is using RHEL 7. In order to allow ec2-user to modify files in apache document root folder, I added the following in CFT (taken from var/log/cloud-init.log)
Jun 30 16:11:15 ip-10-205-0-135 cloud-init: groupadd www Jun 30 16:11:16 ip-10-205-0-135 cloud-init: usermod -a -G www ec2-user Jun 30 16:11:16 ip-10-205-0-135 cloud-init: chown -R root:www /var/www Jun 30 16:11:16 ip-10-205-0-135 cloud-init: chmod 2775 /var/www Jun 30 16:11:16 ip-10-205-0-135 cloud-init: find /var/www -type d -exec chmod 2775 {} \; Jun 30 16:11:16 ip-10-205-0-135 cloud-init: find /var/www -type f -exec chmod 0664 {} \;
As you can see from log, this went fine. However, when logged under ec2, it gives permission error as below:
[ec2-user#ip-10-206-32-92 html]$ aws s3 sync s3://gfrepo/releases releases download failed: s3://gfrepo/releases/binaries.html to releases/binaries.html [Errno 13] Permission denied: u'/var/www/html/releases/binaries.html' download failed: s3://gfrepo/releases/B1556013/B1556013.jar to releases/B1556013/B1556013.jar Could not create directory /var/www/html/releases/B1556013: [Errno 13] Permission denied: '/var/www/html/releases/B1556013'
I ended up elevating my permission as sudo to complete s3 sync. Not sure why it's giving permission error for ec2-user. Here are the listing of the permissions:
[ec2-user#ip-10-206-32-92 www]$ ls -l total 0
drwxrwsr-x. 2 root www 6 Mar 21 02:33 cgi-bin
drwxrwsr-x. 3 root www 55 Jun 30 16:11 html
[ec2-user#ip-10-206-32-92 www]$ groups ec2-user
ec2-user : ec2-user adm wheel systemd-journal www
As you can see ec2-user is part of www group and www is the owner of html sub-dir
You have to make sure the ec2-user belongs to the group that has write permission
if the directory /var/www/html is owned by root it will not let you write to the folder.
first do you an ls -l on /var/www/html
find out what's the group name, it's next to user
then issue this command
sudo usermod -a -G www ec2-user
You need to add ec2-user to the www group
You're logged in ec2-user, although you're issuing an aws s3 sync command, you need permission to write to the permissible directory, that's why it's failing.
This directory /var/www/html/releases/ does not have the permission.
Could not create directory /var/www/html/releases/B1556013 <----
or su to root and try the command.

Resources