SOLVED Problem with default file permission. Something is overriding umask setting

Jelf

Active Member
Jun 26, 2016
36
4
58
Redmond
cPanel Access Level
Root Administrator
My server uses CENTOS 6. (I am upgrading to 7 this next weekend)
When I use Filezilla (SFTP) to upload php scripts the permission is set to 664 and the script cannot be used until I change the permission to 644. I do not think that Filezilla is the problem.

Using SSH I confirmed that umask = 022, which is correct.
Since that umask setting should result in the desired file permission of 644 there must be a setting somewhere that is overriding the system umask setting.

I downloaded /etc/profile and saw these lines:
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi

I changed unmask 002 to 022, uploaded the profile and restarted my server.
That had no effect. PHP files that I upload still get a permission of 664 which is wrong.

Where else should I look to find whatever is overriding the system umask?
I am still a bit of a novice admin so please do not be too cryptic with any advice.
 

andrew.n

Well-Known Member
Jun 9, 2020
982
363
63
EU
cPanel Access Level
Root Administrator
What if you upload the files using FTPS or FTP? How about uploading the files via cPanel File Manager? permissions are okay then?
 

Jelf

Active Member
Jun 26, 2016
36
4
58
Redmond
cPanel Access Level
Root Administrator
Not sure how to get the "Solved" tag on my post.

Here is the solution that worked for me.

Edit the file /etc/ssh/sshd_config

I changed this line
Subsystem sftp /usr/libexec/openssh/sftp-server
to
Subsystem sftp /usr/libexec/openssh/sftp-server -u 022

Note the umask setting.
 
  • Like
Reactions: andrew.n