This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.
Warning: FTP is inherently insecure. If you must use FTP, consider securing your FTP connection with SSL/TLS. Otherwise, it is best to use SFTP, a secure alternative to FTP.
The first two letters of vsftpd stand for "very secure" and the program was built to have strongest protection against possible FTP vulnerabilities.
You can quickly install vsftpd on your virtual private server in the command line:
sudo apt-get install vsftpd
Once the file finishes downloading, the VSFTP will be on your droplet. Generally speaking, it is already configured with a reasonable amount of security. However, it does provide access on your VPS to anonymous users.
Once vsftpd is installed, you can adjust the configuration.
Open up the configuration file:
sudo nano /etc/vsftpd.conf
The biggest change you need to make is to switch the Anonymous_enable from YES to NO:
anonymous_enable=NO
Prior to this change, vsftpd allowed anonymous, unidentified users to access the server's files. This is useful if you are seeking to distribute information widely, but may be considered a serious security issue in most other cases.
After that, uncomment the local_enable option, changing it to yes and, additionally, allow the user to write to the directory.
local_enable=YES
write_enable=YES
Finish up by uncommenting command to chroot_local_user. When this line is set to Yes, all the local users will be jailed within their chroot and will be denied access to any other part of the server.
chroot_local_user=YES
Save and Exit that file.
Because of a recent vsftpd upgrade, vsftpd is "refusing to run with writable root inside chroot". A handy way to address this issue to is to take the following steps:
mkdir /home/username/files
chown root:root /home/username
Then, as always, restart:
sudo service vsftpd restart
Once you have installed the FTP server and configured it to your liking, you can now access it.
You can reach an FTP server in the browser by typing the domain name into the address bar and logging in with the appropriate ID. Keep in mind, you will only be able to access the user's home directory.
ftp://example.com
Alternatively, you can reach the FTP server on your virtual server through the command line by typing:
ftp example.com
Then you can use the word, "exit," to get out of the FTP shell.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Former Director of Community at DigitalOcean. Expert in cloud topics including LAMP Stack, CentOS, Ubuntu, MySQL, SSL certificates, and more.
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!
I still can’t make directory or file under /home/username, how to fix it?
Thx
You will want to create a sub-directly inside of /home/username/sub-directory which is owned by username and upload your files there.
We’ll also review this documentation and clean it up a bit to make it easier for future installs.
Thanks.
I had to make each directory individually. (i.e. mkdir /username then mkdir /files, etc.
If you want to create a multi-directory path that doesnt exist you can add the -p flag to the mkdir command:
Hello I just setup a Virual Host on my VPS, I have it set were there web file are in /home/user/public_html
It lets me log in and see the public_html but when I try to upload a file it uploads it but does not show up in the public_html. How can I fix this issues?
Thanks
i setup vsftp, how i setup a new subdomain in ‘/var/static1’, with it own ftp user and password, that can not acces to the rest of directory server
Hi, I was able to follow all the steps but when I try to move ownership of /home/demo/files using chown I get Operation not permitted but when I used the sudo command that seemed to resolve it. However when I try to connect to the ftp site using FileZilla i get vsftp refusing to run with writable root inside chroot()
@jamie.m.garner: It sounds like you took the chown root:root off the /home/demo folder Run that command again: chown root:root /home/demo… and then to give correct access to the files command use chown -R demo /home/demo/files
jhawk, make sure you are in the correct directory when you are uploading the files. I am assuming you are using a FTP client like filezilla. When you are in that program, make sure that you drag the files to the correct folder from your computer.
pescadito, set your user’s home directory to /var/static1, ensuring that the directory is owned by root. The process is explained in the tutorial above in Step2
Hello, whenever I try to use the ‘chown root:root /home/“my username”’, I get a message saying the operation is not permitted. Unless I need to be logged in as the root to transfer the ownership rules. Please tell me a fix?
I fixed my earlier problem, but now when i log into the ftp server, i am restricted to the root and can’t make anymore folders such as “public_html” for my files. I’ve user mkdir and doesn’t work. Any help?
You can only change ownership to root:root as the root user.
Root can change permissions for any other users.
You should instead change the ownership of the directory to : chown username /home/username
The way you did it currently it would be owned by root so no one other than the root user would be able to create directories, write files, etc.
Having an issue with vsftpd allowing me to authenticate in that it claims my pw is not correct. However, a general note for this and perhaps other docs. Put in the command(s) necessary to uninstall the package.
You can also check the error log to see if there is any additional information provided. Whether its an auth failure or if it’s perhaps something to do with permissions or configuration.
I setup as the tutorial suggested but seem to be having connection problems. First I will state that I have mad a couple of alterations. I uncommented write_enable=YES and added user_subtoken=$USER & local_root=/home/$USER/files to attempt to jail the user into the files folder in their home directory. This seems to cause some sort of conflict throwing the error “500 OOPS: vsftpd: refusing to run with writable root inside chroot()” I’m hoping you can shed some light on this. Thanks
I’ve always used this tutorial: http://www.noob2geek.com/linux/setup-vsftpd-debian-ubuntu/
the only thing you need to add is:
‘sudo chmod a-w /var/www/your_ftp_directory’
‘sudo mkdir /var/www/your_ftp_directory/new_directory’
to get 'round the ‘error "500 OOPS: vsftpd: refusing to run with writable root inside chroot()’ error.
Hope this helps…
very poor explanation… Which domain you refer to?? Is it the IP adress emailed in the droplet creation??
It is the IP emailed to you; or, if you site a set up on that droplet, it would be the domain name for it.
For all the people who want to allow external folders to be available in your ftp, here is a quick tip:
mkdir /home/username/www mount --bind /var/www/path/to/your/folder/ /home/username/www sudo nano /etc/fstab
-and add the following line in the file and save /var/www/path/to/your/folder /home/username/www none bind 0 0
-restart sudo service vsftpd restart
-now you will be able to access /var/www/path/to/your/folder in your ftp.
Hope this helps alot of people out there!
I had vsftpd up and running when I first started my droplet. When I decided to start my droplet over I can not get vsftpd to work. When I try to connect with Transmit or Filezilla I get the following error
“Error -203: miscellaneous error occurred while trying to login to the host”
Any idea how to trouble shoot this?
Hi
I’ve followed the tutorial, yet appear to have permission problems. When I try to create a new theme folder via Filezilla in wp-content/themes I get the error message: “550 permission denied. Critical file transfer error”
I also can’t delete files and puzzlingly when I install a theme via wordpress it doesn’t show up in the FTP file tree. Any ideas?
Cheers
Hey grozanc,
Log in as root, create the folder you want to access via ftp (in your home folder).
Then ‘chown root:root /home/youruser’.
This will fix the issue. It’s like mentioned in the article, the new vsftpd does not let you log in with ‘writable root inside chroot’, which, if you check transmit’s log file, is what’s happening.
That aside, here’s a question for the other members: Since we are limited to ftp user’s home directory, is it wise to move my www folder there as I want to run my droplet as a web server? I’m guessing I will also have to change the ServerRoot variable in Apache to point to my ftpuser’s www folder?
Thanks and good job DO for providing such an affordable hosting solution.
So how exactly do I access /var/www/ in FTP ? I can only see the /files/ folder I have created using this tutorial…
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.