Now that you have a working server that is secured and backed up, you'll want to upload your web content to the server. When you think of transferring files, you probably think of the File Transfer Protocol (FTP) because it has been around for so long. While simple to use, FTP has become obsolete because it lacks the ability for secure file transfers.
Instead, we recommend installing and using a secure file transfer mechanism, and we will introduce you to a few of them in this guide. This article will show you how to install vsftpd (very secure FTP daemon), and will walk you through setting the daemon to work on reboot.
Contents |
Luckily for us CentOS makes this super easy with the group install available in YUM. No need to search out all the dependencies and added features you might want. Use the following command to install everything you'll need:
sudo yum install vsftpd
The service command makes life simple in CentOS, here is how you startup vsftpd:
sudo service vsftpd start
Wow, that was quick, we've got a working install of vsftpd already on the server. Lets go ahead and make a couple of configuration changes for security and convenience.
The 'chkconfig' tool in CentOS is your friend, you can use this tool to check which services will start on boot and on which run level they'll start with. To get Vsftpd to start on the most common run levels(3,4,5) you can use:
sudo chkconfig vsftpd on
Verify the "on" status by checking the complete chkconfig output:
chkconfig --list
or for specific output
chkconfig --list vsftpd
The standard vsftpd configuration file and all subsequent files for CentOS will reside in /etc/vsftpd/ the most important being vsftpd.conf. We need to make two changes to this file for security and convenience:
OPEN up /etc/vsftpd/vsftpd.conf in your favorite editor:
Change: # Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=YES
to read:
# Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=NO
Change:
# You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). chroot_list_enable=YES # (default follows) chroot_list_file=/etc/vsftpd/chroot_list
to read:
# You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). chroot_list_enable=NO # (default follows) chroot_list_file=/etc/vsftpd/chroot_list
pasv_min_port=3000 pasv_max_port=3050
chroot_local_user=YES
sudo touch /etc/vsftpd/chroot_list
iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 3000:3050 -j ACCEPT iptables -I RH-Firewall-1-INPUT -m tcp -p tcp --dport 21 -j ACCEPT%

Comments
vsftp - 500 OOPS: cannot change directory
After following all the above steps we're getting the followoing error:
Re: Cannot change directory
For the iptables
it should be noted that in order to do the iptables part I had to run
iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 3000:3050 -j ACCEPT
for iptables
I had to use
iptables -I INPUT 1 -p tcp --dport 3000:3050 -j ACCEPT
or I got a "No chain/target/match by that name" error
Port 21
The article doesn't mention it specifically, but port 21 should also be opened in addition to the 3000 passive port range,
iptables -I RH-Firewall-1-INPUT -m tcp -p tcp --dport 21 -j ACCEPT
Re: port 21
A good point Anh, thanks. We'll add that to the article.
image links broken in article
image links broken in article. not sure what results of chkconfig --list vsftpd should look like!
thanks!
Open in favorite editor?
How do I open up /etc/vsftpd/vsftpd.conf in my favorite editor?
I am using this command to open up the file:
vi /etc/vsftpd/vsftpd.conf
I am unsure how to save changes and get out of this mode. How does one do this?
Re: vi
Sorry about that. Some quick commands you can use in vi:
i - Insert text
escape - Stop inserting text
x - delete character under cursor
dd - delete line
:q! - quit without saving
:wq - Save and quit
Add new comment