Is there any way to change the file permission of the file while doing SFTP?

2

1

As I send a file via SFTP to a windows server. When I do this,the default file permission will be 640.

there we have a scheduler task which will run on a particular time to grab the files. Due to the file permission 640, it can't access the file.

Both sftp user and the scheduler both are same use( i.e xmfer).

Is there any way to change the file permission of the file on the above scenario ?

sathishkumar

Posted 2013-12-10T04:15:26.783

Reputation: 21

2What do you use to do SFTP? I used PSFTP (part of the PuTTY bundle) and they can do chmod to change the file permission. And also why would you have this issue when putting the file into Windows Server as to my knowledge file permission 640 is for unix-bound file, or am I missing something? – Darius – 2013-12-10T04:25:49.053

+1 to Darius, Piece of cake under Linux. Too bad you have to stick to windows SFTP server. – xpt – 2013-12-10T04:32:58.370

If the SFTP server supports POSIX ACL 1 2, you can also define default access rights on directories so that newly created files in them will have these access rights.

– pabouk – 2013-12-11T11:08:29.030

Answers

0

First, it's a Windows server, while the 777-style permissions is *nix thing, so it does not make a sense. Some SFTP servers (for instance OpenSSH server running on Cygwin) may try to map 777-style permissions to Windows file-system permissions, but the results may not be, what you like.

Also even the perceived 640 permissions are not actual, it's just your SFTP server (or event the client possibly) mapping of Windows file-system permissions to the 777-style permissions. The simple 777-permissions may not even remotely span complexity of Windows file-system ACL permissions.

Another thing is how to set the permissions on the client. But for that, we need to know, what SFTP client you are using.

For instance WinSCP allows setting remote file permissions both during transfer and ex-post. Both in GUI:
https://winscp.net/eng/docs/ui_transfer_custom
https://winscp.net/eng/docs/ui_properties
and scripting:
https://winscp.net/eng/docs/scriptcommand_put
https://winscp.net/eng/docs/scriptcommand_chmod

PuTTY psftp has the chmod command.

Also newer versions of the SFTP protocol allow setting complex file-system permissions. But this is supported only by few servers and clients (I believe that Vandyke does, not sure though).

Martin Prikryl

Posted 2013-12-10T04:15:26.783

Reputation: 13 764