Home / How to apply specific file permission on file uploaded with Linux SFTP?

How to apply specific file permission on file uploaded with Linux SFTP?

The specific file permissions on files uploaded with SFTP can be set using -u(umask) for directory permission and -m for required file permission.

If the permission for an uploaded file needs to be 664 and the permission for a directory needs to be 775, then the following example can be considered.

Match User ftp_user 
ChrootDirectory /sftp/%u
ForceCommand internal-sftp -u 002 -m 664

Manpage shows the following info:

-m force_file_perms
Sets explicit file permissions to be applied to newly-created files instead of the default
or client requested mode. Numeric values include: 777, 755, 750, 666, 644, 640, etc.
Using both -m and -u switches makes the umask (-u) effective only for newly created
directories and explicit mode (-m) for newly created files.

Leave a Reply