Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Using a fresh installation of CENTOS 6.2, when I connect to the server ( SFTP mount with nautilus ) and edit files, no matter what permission the file had before, it is reset to 700, read+write+execute only for the owner. When SSHing directly into the machine and editing files on the command line - no permissions are changed.

The files I am editing are website scripts sitting in my Apache folders.

Why is this behavior happening? Any suggestions are welcome.

share|improve this question
add comment

2 Answers

What are you using to "edit" the files while SFTP-mounted?

If it's a GUI app, it might be creating a new file, deleting the old one, and renaming the new one to match the old, instead of just "editing" the existing one.

If this is the case, the new file would be created with the default mask.

share|improve this answer
    
Im using graphical vi, but I observed the same behavior when editing with vi from the command line. –  Lix Dec 29 '11 at 7:33
add comment
up vote 0 down vote accepted

Solution I found was to use SSHFS and set the umask as an SSH option.

sshfs -o umask=0133 root@remote_machine_address:/ /desired_mount_point

Setting the umask in /etc/profile and the ssh config files had no affect when mounting SFTP with nautilus.

share|improve this answer
1  
Getting sftp-server to obey a umask is extremely difficult. The only way I've ever gotten it to work is via an ugly hack, like this: jeff.robbins.ws/articles/… –  Keith Dec 28 '11 at 22:59
    
sshfs seems to obey the umask I pass it. My problem with sshfs is that it does not handle connection drops at all. I have an unstable internet connection and it disconnects and reconnects quite often - when using a browser these drops are not an issue because a simple refresh after a few seconds will let me continue browsing. Files that were mounted with sshfs however, are unaccessible, I am unable to unmount the volume and my file browser (nautilus) becomes interrubtable. –  Lix Dec 29 '11 at 7:37
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.