Uploading via FTP to apache webfolder

I am hoping someone can point out what I am doing wrong. Simple setup:

  1. Ubuntu 15.04 Server 64 bit installed
  2. Sudo apt-get install Apache2
  3. Sudo apt-get install vsftpd
  4. Log into the Ubuntu server, navigate to the /var/www/html directory. Created a new directory called "test1"
  5. all good, ftp into the server, all good!
  6. Attempt to put a file into the directory (upload) Permission DENIED? On the server I did set chmod 755 and 777 and neither worked.

What am I missing?

I'd bet it has to do what what group you're in as well as ownership, you must not be in the correct one to have access to be able to write to the folder despite setting the permissions

So for the ownership:

sudo chown -R www-data:www-data /var/www

And for adding yourself to the proper groups:

sudo usermod -a -G www-data <username>
sudo usermod -a -G ftp <username>

and then verify you're in the groups:

groups <username>

Consider using sftp also (ftp over ssh) since ftp isn't encrypted, this is mostly important to protect against MITM attacks so it is probably not necessary if you just connect over your local network.

All you need for this to work is an ssh server and an account that has permission to access /var/www. Preferably configure the ssh server to only let you login to the accounts that you are going to use with it (e.g. you could block access to root). If you only use the ssh server for ftp, use an account for ftp that only has the permissions that is mandatory for accessing /var/www. It's also good to use public key authentication for ssh.

Again, this is mostly necessary if your server is accessible from the internet.

1 Like

Thanks that worked!