Tag Archives: sftp permission 664 and ftp permission 644

Wrong permissions when uploaded over SFTP ?

When uploading files / folders via SFTP, do you get the wrong / unintended permissions ? This might be evident when you get the permission of a file as 664 when uploaded via FileZilla over SFTP, and you get 644 when the same file is done over FTP.

This is due to the different umask setting for the different services.

To change this unintended behavior for SFTP, open the SSH configuration at /etc/ssh/sshd_config. Add this particular line :

Subsystem sftp /usr/libexec/openssh/sftp-server -u 022

022 means the permission for your files will be 644 (rw-r–r–) and for your directories 755 (rwxr-xr-x)

002 means the permission for your files will be 664 (rw-rw-r–) and for your directories 775 (rwxrwxr-x).

Once this is added, restart SSH service !