Question

FTP open for write: permission denied

  • Posted on January 2, 2015
  • TedinozAsked by Tedinoz

Hi I’m new to linux. I have followed v.helpful on-line tutorials to setup CentosOS 6.5, and I have successfully installed LAMP server, SSH and vsftp.

I have setup a second user with the same privileges as root and I can access the droplet via FTP (with FileZilla) as that new user and successfully download a file **but ** I can’t upload any file - whether a new file or an edited version of an existing file. I’ve been trying a simple upload to “/var/www/html” where the owner=root and the group=root.

The error message is: Error: /var/www/html/index.php: open for write: permission denied Error: File transfer failed

I’m sure it is something simple; Any assistance gratefully received.

Ted

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
January 6, 2015
Accepted Answer

Giving the ted user sudo privileges will allow it to execute commands as root, but it will not effect what files it can access over FTP. FTP is only concerned about the user/group that owns the file.

Normally the Apache web root on a CentOS server will be owned by the apache user not the root user. Adding the ted user to the apache group and granting write ACLs to the folder should allow it to access files in that directory over FTP.

chown -R  apache:apache /var/www/html/
sudo usermod -a -G ted apache
sudo setfacl -R -m u:ted:rwx /var/www/html

If anyone is using Ubuntu I used the following to resolve my issue thanks to @asb for pointing me in the right direction:

sudo usermod -a -G YOUR_USERNAME www-data
sudo setfacl -R -m u:YOUR_USERNAME:rwx /var/www/html

Hope this may help others. Thanks again to @asb

Thank you @Infused that solved my issues. However, everytime I create a new file on my server I have to do that, surely there is a better way?

Getting really annoying having to do that everytime haha

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.