SFTP, file permissions, and security

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ceeb
    Junior Member
    • Mar 2004
    • 26

    #1

    SFTP, file permissions, and security

    I use FileZilla to upload files over SFTP. File permissions are always set to 664 (rw-rw-r--) by default.

    Since the MySQL upgrade, I assume some security settings have been changed: PHP pages will not load unless files are set to 644 (rw-r--r--). Whilst I can manually change permissions with SSH/SFTP, it can take a long time with larger sites, e.g. those using WordPress.

    Is there any way to set a default file permission of 644 when a file's uploaded?

    Alternatively, does anyone know of a quick way to safely chmod every subdirectory to 755 and every file within them to 644 (-R works to an extent, but I don't know of a way to identify and separate files and folders)?
  • AndrewT
    Administrator
    • Mar 2004
    • 3655

    #2
    Go ahead and submit a ticket and I'll make sure your umask is set correctly. Please include the username and password. Just FYI, I have seen some (S)FTP clients do some weird things as far as default permissions are concerned.

    Comment

    • AndrewT
      Administrator
      • Mar 2004
      • 3655

      #3
      For anyone else that might be having this problem:

      Login to SSH and run "umask". If it does not return 0022 then you need to edit your .bashrc file and at the end add:

      umask 0022

      Then logout and log back in and the default permissions on new files should be properly set to 644.

      Comment

      • ZYV
        Senior Member
        • Sep 2005
        • 315

        #4
        I would like to add the following -- if you already have a bunch of files and you need to set the correct permissions you may easily do so via SSH like this:

        [user@cpanel public_html]$ find ./ -type f -exec chmod 0644 {} \;
        [user@cpanel public_html]$ find ./ -type d -exec chmod 0755 {} \;
        It will set the correct permissions to the files and directories in the current folder (type pwd to check it out) and this is a recursive action so it will proceed with the nested subfolders. I am not sure this is the most elegant way to achieve this, but anyhow it often helps me while troubleshooting permissions problems.

        Comment

        • ePlanetDesign
          Junior Member
          • Aug 2006
          • 7

          #5
          And... for those of us who hate the command line, WinSCP has "Add X to directories"
          Select any number of directories and/or files, right click, select Properties, set the Octal to 0644, check the Add X checkbox, check the Recursive option checkbox and click OK. If you have a lot of files and directories, it can take a while but it sure is easy.

          Just thought I would throw that out there.

          James

          Comment

          Working...