Link to home
Start Free TrialLog in
Avatar of Thiago Martins
Thiago MartinsFlag for Brazil

asked on

Change permission files inside folder

I have a program that sends the file via ftp, but this file always gets unwritten permission. How do I make this file always be sent with write permission. Or how do I make the files inside this folder always have write permission?
Avatar of Prabhin MP
Prabhin MP
Flag of India image

Basically all FTP clients (cute, filezilla, smart, yafc, etc) have the option to set file permissions.

I have not yet seen any feature / option to permanently persist the file permissions from your computer to the server. However you can in filezilla and in cuteftp ( i use these 2) set an advanced property which will auto apply a permission set of your choice to all files uploaded.

Also, i think this is not likely to ever be released as a feature since file permissions are also based on user! Different users on your computers and different users on your server all of which may or may not have differing permissions.

Hope this helped. Cheers.

PS: let me know if you can't find the option in filezilla or cuteftp


reference:https://stackoverflow.com/questions/6961966/keeping-file-permissions-with-ftp
Avatar of Thiago Martins

ASKER

Thank you for your answer.

But the problem is, this file is updated every 30 seconds. And every with no permission to read.
Once this situation occurs, mention how you get the write bit set on again.

Specifically, as you doing this via your SFTP client or on the server side.

Also, you mention the file updates every 30 seconds. Mention how this occurs. For example, are you saying you have some script that runs SFTP that pushes the file from your local machine to the FTP server every 30 seconds or the server is changing the file every 30 seconds.

Also, mention if you have ssh access to the server where file lives.
> this file is updated every 30 seconds

then users should have permissions to read everything of its folder, not the file itself.
Yes, but. How can I solve this?
Is in software when upload by ftp?
Or in server when recieve this file?
first give Read and Write permission to that folder for given users or group.
I do this.
I set up the folder by SSH all permissions with sudo.

In case, the file is upload every 30 seconds. It is replaced.
You still haven't mentioned how your fix your file permissions.

This will likely be either SFTP or SSH.
By ftp.
Curious.

Provide a dump of an entire session (all commands) you use to upload your file every 30 seconds + then flip on the file's write bit.

Also, you still haven't answered if you have access to your FTP server via SSH. If you do, debugging this problem will be far simpler.
Yes I have access to my serve by SSH.

It is a dropplet in Digital Ocean.
Then, with ssh, look at all the permissions + ACLs of all directories starting with the directory of where your file is deposited.

If the permissions on the file you upload are different on your local machine + remote machine, then the bits are being changed by some sort of FTP server setting or setuid/setgid bits on a directory or ACL on a directory.

You'll just have to go through step by step to determine where change is occurring.

Be sure + read the SFTP server docs of whatever SFTP server you're using. Some of these servers do odd things with permissions.

If you find your SFTP server is changing permissions, you can likely fix this by adding a default ACL to the parent directory, which will be set anytime a file is created/changed.

Or you might consider switching to MySecureShell, which is an SFTP server which works exactly like you'd image this type of server should work. It's zero config + works out of the box.
Is there a Way to set default permission for ftp?
Whether or not you can setup default permissions with SFTP, depends on the SFTP server + SFTP client you're using.

And...

There are only few things which can be happening.

1) You source file permissions don't include a write bit enabled, which your remote SFTP server understands.

2) Your remote FTP server is changing the permissions of all files received based on the SFTP server config or ACLs which have been set.

3) Some other software (usually anti intrusion software) is changing permissions on the fly, due to it's ruleset.

You just have to debug these problems, till you find the root cause... which will determine your fix.
Avatar of dfke
dfke

Hi,

just use 'setfacl' on the desired location to set default rights on the OS level for every file that gets written there:

chmod g+s </path/to/files>  //set gid 
setfacl -d -m g::rwx /</path/to/files>  //set group to rwx default 
setfacl -d -m o::rx /</path/to/files/>   //set other

Open in new window


Next we can verify:

getfacl /</path/to/files/>

Open in new window


Output:

# file: ../</path/to/files/>
# owner: <user>
# group: media
# flags: -s-
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x

Open in new window

Cheers
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.