I am having a problem with SFTP and SCP where files that are copied are not inheriting the permissions of the remote parent directory. I have seen similar questions on serverfault where the umask
of the SFTP/SCP session is modified, however, that does not necessarily solve my issue, as some directories will need to have different permissions than others. Thus, I do not to have a default umask
set.
Thus, I want to force the copied file to have the permissions that are set by the parent directory on the remote system. Basically, I want SCP/SFTP to work the same way that cp
works without the -p
option. Currently SFTP/SCP is mimicking cp -p
behavior.
Here is what I want to have happen:
1.) User wants to copy file foo.txt
with permissions:
-rw-------. 1 user user 0 Feb 29 09:08 foo.txt
2.) User uses SCP to copy foo.txt
to the server under directory /bar
. /bar
has permissions (setgid is set):
drwxrws---+ 3 root usergroup 4096 Feb 28 12:19 bar
3.) /bar
has the following facl's set:
user::rwx group::rwx group:usergroup:rwx default:user::rwx default:group::rwx default:group:usergroup:rw-
4.) foo.txt
should have the following permissions (and facl):
-rw-rw----+ 1 user usergroup 0 Feb 29 09:33 foo.txt user::rw- group::rwx #effective: rw- group:usergroup:rw-
5.) Instead, foo.txt
has permissions:
-rw-------+ 1 user usergroup 0 Feb 29 09:36 foo.txt user::rw- group::rwx #effective:--- group:usergroup:rw- #effective:---
Is there an easy way to get the file obtain expected permissions above?
Also, do my facl's make sense, or are they redundant?
EDIT: Fixed post to display properly. (Serverfault's code and numbering doesn't work too well. I needed to wrap things in pre tags.)