2

When a user creates a folder over SFTP it gets permissions of

drwxr-xr-x

I need it to have

drwxrw-r--

I know i can change the permissions with chmod but it would save me lots of time and effort if the folder could be created with the correct permissions from the start. Is there a way to change the default permissions for when a specific user creates a folder?

a.smith
  • 715

1 Answers1

3

Directories are typically created with all permission bits set (see for example mkdir, when the mode isn’t specified explicitly), except those masked by the current umask, so you can set that for the user you’re interested in;

umask 013

will produce the result you’re after under such circumstances.

For your specific sftp requirements, see Proper way to set the umask for SFTP transactions?

Other approaches can be used if your file system supports ACLs and you don’t need to limit this to a single user; see How to set default file permissions for all folders/files in a directory? for details.

Stephen Kitt
  • 434,908
  • … except for install -d which defaults to 00755. (-: – JdeBP Jan 17 '20 at 11:32
  • Thanks for this, i want this change only to apply to a single user - not sure if this makes a different but the user can only access the server over sftp - when they created a folder is where i saw this behaviour. – a.smith Jan 17 '20 at 11:40
  • Yes, this is specific to a user, the umask is set per process. I’ll have to check whether this is usable over sftp; please add that requirement to the question. – Stephen Kitt Jan 17 '20 at 12:16
  • Im sure this is for a lack of knowledge on my part but i am not clear how to set the umask on my specific user – a.smith Jan 17 '20 at 13:49
  • See the link I added in my answer. – Stephen Kitt Jan 17 '20 at 13:51