Install and configure FTP server (vsFTPd)

T

his tutorial works for CentOS only. For your specific OS tutorial use the tags or serach function in the sidebar area.

Before we set-up our first webpage we have to gain access to our server via FTP client.
To do this we have to install FTP server first - like vsFTPd (Very Security FTP daemon).


It is a lighweight FTP server built with security in mind. - Its scales very efficiently, and many large sites like (ftp.redhat.com, ftp.debian.org, ftp.freebsd.org) currently use vsftpd as their main FTP server of choice. - vsftpd has a lower number of vulnerabilities listed in CVE than ProFTPd but more than PureFTPd. This could be because, since its name implies it is a secure FTP service, or because it is so widely used on large sites – that it is under more scrutiny than the others.

Installation:

type: yum install vsftpd

[root@server][/]
$ yum install vsftpd
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: mirrors.advancedhosters.com
* extras: mirror.atlanticmetro.net
* rpmforge: mirror.teklinks.com
* updates: centosa5.centos.org
15 packages excluded due to repository priority protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.i686 0:2.2.2-11.el6_4.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

......

Total download size: 157 k
Installed size: 344 k
Is this ok [y/N]: y
Downloading Packages:
vsftpd-2.2.2-11.el6_4.1.i686.rpm | 157 kB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vsftpd-2.2.2-11.el6_4.1.i686 1/1
Verifying : vsftpd-2.2.2-11.el6_4.1.i686 1/1

Installed:
vsftpd.i686 0:2.2.2-11.el6_4.1

Complete!
 

type: service vsftpd start
type: chkconfig vsftpd on

[root@server][/]
$ service vsftpd start
Starting vsftpd for vsftpd: [ OK ]

[root@server][/]
$ chkconfig vsftpd on
 

Configuration:

 

Edit configuration file:

nano /etc/vsftpd/vsftpd.conf

ADD this code at the end of file, after the line which contains "tcp_wrappers=YES"

## THIS IS MINE CONFIGURATION
# Enable also logging to file /var/log/vsftpd.log
dual_log_enable=YES
log_ftp_protocol=YES
syslog_enable=NO
# Allow upload/download ASCII mode
ascii_upload_enable=YES
ascii_download_enable=YES
# Welcome banner text
ftpd_banner=Welcome to My Hostinger VPS - Your actions are logged!
# Set ports for passive connection - already opened in our Firewall script - if not - open
pasv_min_port=35000
pasv_max_port=35999
pasv_addr_resolve=NO
pasv_enable=YES
# Set ROOT to directory domains/ in /var/www/html
local_root=/var/www/html/domains

# A little security
# max clients that are logged and IPs logged from at a time
max_clients=10
max_per_ip=10
# Don't let user outside its home directory
chroot_local_user=YES
nopriv_user=ftp
# Disable Anonymous login
anonymous_enable=NO
 

Save and exit.

Restart VSFTPD.

service vsftpd restart

 

Important !!!

Before we log-in - create a directory 'domains' in your /var/www/html directory. If you don't do this - you won't login. In this directory this single user will be login to - and in that directory we will be holding our webpages.

Remeber that we created user 'jtkirk' for the purpose of our IMAP tutorial? So let's use him, of course You are to use own username.

so:

$ cd /var/www/html/
$ mkdir domains
 
 

type: ls -l

[root@server][/var/www/html]
$ ls -l
total 12
drwxr-xr-x 2 root root 4096 Aug 13 00:42 domains
-rw-r--r-- 1 root root 20 Aug 9 10:33 info.php
drwxr-xr-x 11 apache apache 4096 Aug 1 12:51 roundcubemail
 
You see, I create this directory as root so we have to make this directory own by this user which we create it for -> jtkirk in my case:
 
[root@server][/var/www/html]
$ chown jtkirk:jtkirk domains/

[root@server][/var/www/html]
$ chmod 0755 domains/
 

All right.

Login to your VPS via FTP client.


Host: yourdomain.com (or IP)
user: i.e jtkirk (which we created in IMAP tutorial)
password:
Connection Mode : Passive
Port: 21

And hit 'connect'.

Voila!

You could see our previosly installed roundcubemail and domains directories and info.php file listed.