Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to tell winscp to keep the group and permission of my upload file? I am tired of modifying webpages/webapp binaries and needing to change the group to www-data so the server can read them.

If not what app might i use instead? I mostly use winscp for the easy of copy/pasting files onto my linux server and the ease of browsing the filesystem (can go between 2+ folders in a second, no typos)

share|improve this question
add comment

3 Answers

I'm guessing you're having the problem because WinSCP removes existing files before uploading new ones - which should never happen unless you do not have the 'write' permissions on the old file, in which case deleting and replacing is the only way for WinSCP to upload your files.

When creating a new file on Linux, the creator's primary group will be the file's group1, and the permissions will be calculated2 using (0666 & ~umask). The owner can modify permissions, but can only change the file's group into a group he himself belongs to.

In the case of a website, I usually set the setgid bit on the directories, so that all files I create inside become owned by that group:

sudo chown -R :www-data public_html/
find public_html/ -type d -exec chmod g+s {} \;

If the server's filesystem has ACLs enabled, you could also specify default permissions for the group:

setfacl -Rdm g::rX public_html

Or you could skip the "setgid" and "chgrp" steps, and just assign default permissions to the group you want:

setfacl -Rm g:www-data:rX public_html
setfacl -Rdm g:www-data-rX public_html

(The commands with -d set default permissions.)


  1. Unless the directory has the setgid bit, which makes newly created files inherit the directory's group.
  2. Can be influenced using default ACLs on the directory.
share|improve this answer
    
'which should never happen unless you do not have the 'write' permissions on the old file' <-- Thats the thing, the directory is 777 and so are all the files. I do chmod -R 777 ./ constantly then when everything works i fix the bin folder permission –  acidzombie24 Dec 30 '10 at 21:04
add comment

You need to configure WinSCP not to transfer to temporary file (which is then renamed to the target file name). Then WinSCP will directly write to the target file, and keep the permissions/ownership intact.

Go to Prefereces > Transfer > Endurance > Enable Transfer to Temporary Filename.
http://winscp.net/eng/docs/ui_pref_resume

share|improve this answer
add comment
up vote 0 down vote accepted

Set the gid of the folder and it should now keep the group to www-data provided the folder group is also www-data

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.