How To Install and Setting Up vsftpd on CentOS Server
| |How to install Very Secure FTP on your CentOS server. Looking for the way how to upload, download, edit, manage and organize all your website’s files stored remotely in your CentOS server? Using FTP is the perfect choice because the server we are talking about here is the one with no cPanel or any other control panel software so you don’t have access to those files and folders via web-based File Manager. In this page, I’ll tell you how to install vsftpd, a very secure FTP software so you’ll have access to your server via FTP with strongest protection available. At least the FTP connection is protected against most common or basic FTP vulnerabilities.
Once installed and setup, you’ll also need a client app that supports SFTP connection and for me, the most important one it should be a freeware. Need recommendation? Try FileZilla, CoreFTP, WinSCP, and CoffeeCup Free FTP. However you can simply access your server via FTP through a web browser but for download-only purpose, not for uploading.
How to Install VSFTPD
Step 1 – Login to your server and follow my previous guide about Basic setup for CentOS before you build a live web server. You may and may not follow that tutorial but if you followed, it will give you some basic security tweak to your server.
Before you proceed to the next steps, it is better to explain that all commands in this tutorial are written without the “sudo” prefix. However if you disabled root login and you logged in using another username with root privilege, you can add the “sudo” prefix all by your self. Alternatively you can simply type su, hit Enter and type in your password twice to switch login as root.
You may also need to type this command to go to the root directory:
cd ~
Step 2 – Now issue this command syntax to install vsftpd:
yum install vsftpd
You may also need to confirm the install by answering Y.
Once done you’ll see the “Complete!” message.
Step 3 – Next, also install free ftp client software on your server by issuing this command:
yum install ftp
Again, hit Y if asked to confirm.
Step 4 – That’s it. Basically you’ve installed all necessary ftp software on your server. But you may also need to setup several configuration following the next section.
How To Setup VSFTPD Configuration
Step 1 – First thing first, open “vsftpd.conf” file, the file that holds all vsftpd configuration. In this tutorial I’ll use Nano editor.
nano /etc/vsftpd/vsftpd.conf
Step 2 – Disable ftp anonymous login. To do that, find the line below and make sure its value is “no”.
anonymous_enable=NO
Looks like this:
Step 3 – Also make sure the “local_enable” line is uncommented and its value is YES.
local_enable=YES
as shown in my screenshot below:
Step 4 – Now find this “chroot_local_user” line and uncomment (remove the # symbol) and make sure its value is YES.
chroot_local_user=YES
So it looks similar like this:
What does “chroot_local_user=YES” mean? If this line is enabled, all the local users will be jailed within their chroot. It means access to any other part of the server will be denied.
Step 5 – That’s it. Well, basically there are several other configurations you can change / adjust according on your like. But what I’ve mentioned above are the most common settings ensuring your server to get the basic security level for its ftp connection. So once done editing, save that file by hitting Control+O then Control+X to exit.
Step 6 – Finally, restart the vsftpd service by using this command:
service vsftpd restart
It should return with OK message in the “starting vsftpd for vsftpd”.
Step 7 – The very lest step, issue this command:
chkconfig vsftpd on
that last command is aimed to make vsftpd service automatically runs each time your server boot or reboot.
That’s all. Now you can access your server via ftp connection. You can firstly try via your browser by typing:
ftp://domain.com
in my case it looks like this:
Alternatively, you can use your favorite ftp client like FileZilla.
What’s next? Read my previous guide about how to use SFTP to upload and manage files on your server. Alright, have a nice day and let me know if you have curiosity in your mind regarding this topic. Follow me on Twitter to get faster update.
Great tutorial. I follow your complete tutorial from here http://servermom.wpengine.com/complete-newbie-guide-to-build-centos-server-to-host-websites/.
I want to ask, after i set my ftp server following your setup, where do i set up the username and password?
Via SSH connection :
adduser newuser
passwd newuser
Without setting up an ftp server, my VPS already has ftp access, which seems to be integrated with sshd. Downside ? I haven’t been able to deny shell access to a user without disabling its ftp. I haven’t been able to chroot ftp users without jamming the someuser:wheel. (Both feel like a security issue to me.)
So my question how can I solve both either with the “built-in” sftp (coming from sshd), either _disable_ that and make sure the vsftpd doesn’t conflict with what’s already there (sshd mostly I presume) ?
i received error “550 failed to change directory” when access via ftp://domain.com
I had to change my protocol in Filezilla to SFTP, then it worked just fine! Wouldnt know how to reach it through my browser. Only in Filezilla it lands in the home dir, and i can access all other dirs. But I’ll dig into that 🙂 Thanks for the clear tuts, much appreciated.
I received alert “530 permission denied.”
Hi ive installed everything but the only issue i’m having is that when i login as user1 for example i get the contents of the /var/www/ directory and the same if i login as user2 i get that directory.
How do i get it so that user1 (domain2.com) goes to /var/www/domain1/
and user2 (domain2.com) goes to /var/www/domain2
Many thanks
P.s. Excellent tutorials helped me enormously 🙂
Try: this or this tutorial. I hope that may help you 🙂
Starting vsftpd for vsftpd: 500 OOPS: unrecognised variable in config file: chroot_local_user
do you have any clue to figured it out mbak ?
I’m really thankful for your effort and time on creating this amazingly clear tutorial.
You are awesome!
hey, thanks for the complete tutorial, but i have a problem, when i connect using filezilla or with browser, the directory is empty, and when i delete theme in wordpress, it need “connection information” and i need to insert ftp username and password, but after that, the theme isn’t deleted yet, i follow along ur tutorial, i think i don’t missing some part, any idea why? thanks 🙂
the problem :
http://prntscr.com/8kddju
Dear Sawiyati,
Amazing blog and greatly detailed. Frankly, the most well written and dummy ready blog I have every seen. Keep it up.
Best Regards,
Saumitra
This is a great article. Thanks for your great help! here I have a quick question. I followed your guide step by step and after I login into my FTP server, there are no folder and directory. It should show the folder that contains those word press related files.
I was thinking maybe it was the user permission but I couldn’t figure out.
Thank you in advance.