0

This question already has an answer here:

I have an application that uploads a file via SFTP using sftpuser. Once the file is uploaded the owner and group is user1:user1. The owner of the parent directory is apache:apache. I can not figure out how the file is being associated to user1.

Any thoughts on where I should look or how to resolve this issue? I would like the file to inherit the owner/group and permissions from the parent directory.

marked as duplicate by cas, garethTheRed, Rahul, Jakuje, Networker Jun 28 '16 at 13:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If I do a chown sftpuser:sftpuser ./ the owner is changed to user1??? Here is what I have in my passwd file. sftpuser:x:502:503::/home/sftpuser:/bin/bash user1:x:503:504::/home/user1:/bin/bash – bmass Jun 28 '16 at 20:51
  • I resolved my issue. The directory was part of a mounted nsfshare. The UID for sftpuser was 502 on one server and 502 for user1 on the other. – bmass Jun 29 '16 at 3:06
0

Do you have an entry for user1 in your /etc/passwd ? If you want to change the ownership of the directory you can type as root: chown apache:apache /var/www -R You can also add user1 to apache group and in this way your web server will fine. Maybe it's good idea to read the following topic:

How can I create an SFTP user in CentOS?

  • yes, user1 is a valid user. I know I can manually change the permission but I don't want to login every time a file is uploaded to do so. User1 is not the owner of any of the directories in question nor is it used to upload the files. I have no clue how the files are associated with user1 – bmass Jun 28 '16 at 20:39

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