Install vsftp Server On CentOS / RHEL / Scientific Linux 6.4
vsftpd (Very Secure File Transport Protocol Daemon) is a secure, fast FTP server for Unix/Linux systems. In this how-to article, let us see how to setup a basic FTP server using vsftpd on CentOS 6.4.
My testbox server hostname and IP Address are ftp.unixmen.com and 192.168.1.200/24 respectively. Change the values as per your scenario.
Run the following command in terminal to install vsftpd package:
[root@ftp ~]# yum install vsftpd ftp -y
Start the vsftpd service and make it to start automatically on every reboot:
[root@ftp ~]# service vsftpd start Starting vsftpd for vsftpd: [ OK ] [root@ftp ~]# chkconfig vsftpd on
Open the vsftpd configuration file /etc/vsftpd/vsftpd.conf. Find the following lines and make the changes as shown below:
[root@ftp ~]# vi /etc/vsftpd/vsftpd.conf [...] ## Set to "NO" ## anonymous_enable=NO ## Uncomment ## ascii_upload_enable=YES ascii_download_enable=YES ## Uncomment - Enter your Welcome message - This is optional ## ftpd_banner=Welcome to UNIXMEN FTP service. ## Add at the end of this file ## use_localtime=YES
Restart vsftpd service:
[root@ftp ~]# service vsftpd restart Shutting down vsftpd: [ OK ] Starting vsftpd for vsftpd: [ OK ]
Create FTP users
By default, root user is not allowed to login to ftp server for security purpose. So let us create a testing user called “sk” with password “centos”:
[root@ftp ~]# useradd sk [root@ftp ~]# passwd sk Changing password for user sk. New password: BAD PASSWORD: it is based on a dictionary word BAD PASSWORD: is too simple Retype new password: passwd: all authentication tokens updated successfully.
Connecting to FTP server
Now let us try to connect to FTP server itself with user “sk”:
[root@ftp ~]# ftp 192.168.1.200 Connected to 192.168.1.200 (192.168.1.200). 220 Welcome to UNIXMEN FTP service. Name (192.168.1.200:root): sk 331 Please specify the password. Password: 500 OOPS: cannot change directory:/home/sk Login failed. ftp>
Probably you will get an error like “500 OOPS: cannot change directory”.
This is because your SELinux restricts the user to login to ftp server. So let us update the SELinux boolean values for FTP service:
[root@ftp ~]# setsebool -P ftp_home_dir on
Now try again to login to FTP server:
[root@ftp ~]# ftp 192.168.1.200 Connected to 192.168.1.200 (192.168.1.200). 220 Welcome to UNIXMEN FTP service. Name (192.168.1.200:root): sk 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp>
Now you will be able to login to FTP server without any problems.
Client side configuration
As we seen in the above output the user “sk” logged-in to the FTP server from the same system itself. But what if we try to login to FTP server from other client systems? Let us try to login to the FTP server from client system. Here I use Ubuntu 12.10 desktop as my client.
sk@sk:~$ ftp 192.168.1.200 ftp: connect: No route to host ftp>
You might see the above error like “ftp:connect:No route to host”. To resolve this issue, allow the default ftp port “21″ through your firewall or router. In the server side, do the following:
[root@ftp ~]# vi /etc/sysconfig/iptables [...] -A INPUT -p udp -m state --state NEW --dport 21 -j ACCEPT -A INPUT -p tcp -m state --state NEW --dport 21 -j ACCEPT [...]
Save and exit the file. Restart iptables now:
[root@ftp ~]# service iptables restart
Now try again from the client system to login to FTP server:
sk@sk:~$ ftp 192.168.1.200 Connected to 192.168.1.200. 220 Welcome to UNIXMEN FTP service. Name (192.168.1.200:sk): sk 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp>
Boom!! It’s working now.
Working from command-line mode might be little bit annoying to newbies. So let us install a graphical FTP client called Filezilla to get things done quite easier:
sk@sk:~$ sudo apt-get install filezilla
Open Filezilla client from your client system “Dash” or “Menu”. Enter the FTP server hostname or IP Address, username, password and port number. Click “Quickconnect” to login.
Probably you will get an error like in the above screenshot:
Error: Connection timed out Error: Failed to retrieve directory listing
Resolve this issue by disabling the firewall (iptables) completely. If you don’t want to disable firewall, do the following resolutions. In most cases Resolution 2 should work.
1. In your Filezilla client go to Edit -> Settings -> FTP ->Active Mode.
In the Active Mode tab, make sure that you have selected the option “Ask your operating system for the external ip address”.
Then again goto Edit -> Settings -> FTP ->Passive Mode. Select “Fall back to active mode” and click OK.
Now the error will be gone in some cases (May be in Windows OS clients).
If the problem still persists, goto your FTP server, open the file “/etc/sysconfig/iptables-config”. Find the line IPTABLES_MODULES=” “ and change this to IPTABLES_MODULES=”ip_conntrack_ftp”:
[root@ftp ~]# vi /etc/sysconfig/iptables-config # Load additional iptables modules (nat helpers) # Default: -none- # Space separated list of nat helpers (e.g. 'ip_nat_ftp ip_nat_irc'), which # are loaded after the firewall rules are applied. Options for the helpers are # stored in /etc/modprobe.conf. IPTABLES_MODULES="ip_conntrack_ftp" [...]
Save and restart iptables:
[root@ftp ~]# service iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] [root@ftp ~]# service iptables restart iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules: [ OK ] iptables: Loading additional modules: ip_conntrack_ftp [ OK ]
Now try again from Filezilla. Yes! It works now.
You can access the FTP server from your client browser also. Navigate to ftp://FTP-Server-IP-Address/. Enter the username and password.
Login using a particular user
If you want to login using a particular user, then navigate to ftp://username@FTP-Server-IP-Address/. It will ask the password of user, enter the password and you’re done. Create a another test user called “kumar” with password “centos”:
[root@ftp ~]# useradd kumar [root@ftp ~]# passwd kumar Changing password for user kumar. New password: BAD PASSWORD: it is based on a dictionary word BAD PASSWORD: is too simple Retype new password: passwd: all authentication tokens updated successfully.
Now open your browser and navigate to ftp://email@example.com. Enter the password of the user kumar. Now you will able to connect to FTP server.
That’s it. Start using FTP.
Like us on Facebook
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- Manage Databases And Hosted Servers Remotely With DbNinja : Database administration via command line is bit difficult for newbie system and database administrat...0 comments |
- Setup IT And Asset Management System With GLPI On Debian/Ubuntu : GLPI is the Information Resource-Manager with an additional Administration Interface. You can use it...0 comments |
- How To Configure Linux Clients To Authenticate Using OpenLDAP : This is the continuation of our previous tutorial. In our previous tutorial we learned how to instal...0 comments |
- How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander : Ubuntu 13.10 Saucy will be released on October 17th. Hope it will come with lot of improvements and ...0 comments |
- Install FrostWire 5.6.9 In Elementary OS 'Luna'/ Ubuntu / Linux Mint : FrostWire is a peer-to-peer file sharing program for the gnutella and BitTorrent protocols. FrostWir...1 comment |
- How To Install Linux Kernel 3.12.4 In Ubuntu
- Firefox 26 Has Been Released, How To Install It In Ubuntu And Its Derivates
- How To Install Brasero In Elementary OS ‘Luna’
- Install Sayonara Player In Elementary OS / Ubuntu / Linux Mint
- Manage Databases And Hosted Servers Remotely With DbNinja
- Install FrostWire 5.6.9 In Elementary OS ‘Luna’/ Ubuntu / Linux Mint
- Setup IT And Asset Management System With GLPI On Debian/Ubuntu
- How To Configure Linux Clients To Authenticate Using OpenLDAP
- How To Install Netflix In Ubuntu
- cowsay And fortune Combined Together
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .