4

I have been trying to figure out what is wrong with the file rights. When I am uploading files using FileZilla all the files get rights -rw-r--r--. I would want them to have -rwxr-xr-x. I have tried using umask to fix the rights but something is wrong. I have read that you could change the rights with umask like this for example:

In /etc/ssh/sshd_config, change the following:

Subsystem sftp /usr/lib/openssh/sftp-server -u 002

With this change I am getting files with -rw-rw-r--. As far as I know 0 should give all rights? But I am getting rw only.

Whats wrong? I am using Debian.

3
  • try 0002 instead of 002.
    – vautee
    Nov 18, 2014 at 8:46
  • That also results in -rw-rw-r--
    – Firze
    Nov 18, 2014 at 8:56
  • just remember... two rights don't make a wrong
    – jammypeach
    Nov 18, 2014 at 15:09

1 Answer 1

10

If an SFTP client does not specify permissions for uploaded files, the OpenSSH SFTP server assigns 0666 permissions to newly created files (minus the umask 0002 makes the 0664).

This is hard-coded, you cannot change it. See the process_open() function in the sftp-server.c of OpenSSH. And even, if this was not specified explicitly, the 0666 is still the *nix default for files, you cannot just change this with umask (that's true in general, not just for OpenSSH).

See also Does OpenSSH SFTP server use umask or preserve client side permissions after put command (chrooted environment)?

Note that your umask is actually wrong. If you want 0644, use umask 0022, not 0002.

The FileZilla never specifies permissions for uploaded files. What results in the behavior you are experiencing.


To achieve your desired permissions:

  • With FileZilla you can change the file permissions only manually, after the upload, using File permissions command from a remote file context menu.

    Changing permissions in FileZilla

  • Use an SFTP client that allows specifying the permissions for the uploaded files.

    For example WinSCP allows that.

    See https://winscp.net/eng/docs/ui_transfer_custom

    Setting permissions for uploaded files in WinSCP

    (I'm the author of WinSCP)

1
  • 2
    I switched to WinSCP and did as you instructed and now everything works.
    – Firze
    Nov 18, 2014 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .