In this tutorial we will learn how to install and configure VSFTP server.In this practical we will disable the Anonymous login and will allow system user to login with password.

This tutorial is 2nd part of the post How to install and configure FTP server in Ubuntu 12.04 LTS

Note: We will install the vsftpd 3.0 package after downloading it into the system.
We are not going to use “apt-get install” method .
The reason it has bug related to chroot enable.
For reference :
https://sharadchhetri.com/2013/05/20/500-oops-vsftpd-refusing-to-run-with-writable-root-inside-chroot

To install and configure the FTP Server ,follow the given below steps

Step 1 : Login with superuser and download and install vsftpd package

    tux@ubuntu:~$ sudo su -
    [sudo] password for tux:
    root@ubuntu:~#
    root@ubuntu:~# cd /root/
    root@ubuntu:~# wget http://security.ubuntu.com/ubuntu/pool/main/v/vsftpd/vsftpd_3.0.2-1ubuntu2_i386.deb
    –2013-05-20 09:36:20– http://security.ubuntu.com/ubuntu/pool/main/v/vsftpd/vsftpd_3.0.2-1ubuntu2_i386.deb
    Resolving security.ubuntu.com (security.ubuntu.com)… 91.189.92.190
    , 91.189.92.201, 91.189.92.202, …
    Connecting to security.ubuntu.com (security.ubuntu.com)|91.189.92.190|:80… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: 114714 (112K) [application/x-debian-package]
    Saving to: `vsftpd_3.0.2-1ubuntu2_i386.deb’

    100%[=========================================================================================>] 114,714 219K/s in 0.5s

    2013-05-20 09:36:21 (219 KB/s) – `vsftpd_3.0.2-1ubuntu2_i386.deb’ saved [114714/114714]

    root@ubuntu:~#
    root@ubuntu:~#
    root@ubuntu:~# dpkg -i vsftpd_3.0.2-1ubuntu2_i386.deb
     
    Install the dependency of vsftpd

      root@ubuntu:~# apt-get install libcap2

Step 2 : Backup the vsftpd.conf file and edit the given below parameters in vsftpd.conf file.Then restart the vsftpd service.

# cp -p /etc/vsftpd.conf.dpkg-new /etc/vsftpd.conf
# cp -p /etc/vsftpd.conf /etc/vsftpd.conf.orig
# vi /etc/vsftpd.conf

anonymous_enable=NO
local_enable=YES
write_enable=YES

# service vsftpd restart

Note: You can create directly /etc/vsftpd.conf file rather than following just above given steps. Below section has my vsftpd.conf file settings, you can copy and paste the content in your server /etc/vsftpd.conf file.

My /etc/vsftpd.conf is configured like this

root@ubuntu:~# egrep -v '^#|^$' /etc/vsftpd.conf
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
root@ubuntu:~# 

Step 3: Now login into FTP server with command line ,web browser or using FTP client(filezilla) .
Give System username and password.After login you can start downloading and uploading the files into FTP server
Note: Bydefault user will login into its home directory (eg. /home/joe)

Below is eg. with command line

linux@tuxworld:/tmp$ ls -l
total 24
drwx------ 2 linux   linux   4096 May 21 07:35 CRX_75DAF8CB7768
drwxrwxr-x 2 linux   linux   4096 May 21 07:18 emptydir
drwx------ 2 linux   linux   4096 May 21 07:27 pulse-0VcDFPK5pDDt
drwx------ 2 lightdm lightdm 4096 May 19 07:49 pulse-2L9K88eMlGn7
drwx------ 2 root    root    4096 May 19 07:48 pulse-PKdhtXMmr18n
drwxrwxr-x 2 linux   linux   4096 May 21 07:19 testdir
-rw-rw-r-- 1 linux   linux      0 May 21 07:19 testfile1
-rw-rw-r-- 1 linux   linux      0 May 21 07:19 testfile2
-rw-rw-r-- 1 linux   linux      0 May 21 07:19 testfile3
-rw-rw-r-- 1 linux   linux      0 May 21 07:19 testfile4
linux@tuxworld:/tmp$ 
linux@tuxworld:/tmp$ ftp 10.10.0.25
Connected to 10.10.0.25.
220 (vsFTPd 3.0.2)
Name (10.10.0.25:linux): tux
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> put testfile1
local: testfile1 remote: testfile1
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-------    1 1000     1000            0 May 20 11:46 testfile1
-rw-------    1 1000     1000       231190 May 20 05:26 ubuntu.jpg
-rw-r--r--    1 1000     1000       199818 May 20 06:05 vsftpd_3.0.2-2_all.deb
226 Directory send OK.
ftp> mput testfile2 testfile3 testfile4
mput testfile2? y
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
mput testfile3? y
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
mput testfile4? y
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-------    1 1000     1000            0 May 20 11:46 testfile1
-rw-------    1 1000     1000            0 May 20 11:47 testfile2
-rw-------    1 1000     1000            0 May 20 11:47 testfile3
-rw-------    1 1000     1000            0 May 20 11:47 testfile4
-rw-------    1 1000     1000       231190 May 20 05:26 ubuntu.jpg
-rw-r--r--    1 1000     1000       199818 May 20 06:05 vsftpd_3.0.2-2_all.deb
226 Directory send OK.
ftp> get ubuntu.jpg
local: ubuntu.jpg remote: ubuntu.jpg
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for ubuntu.jpg (231190 bytes).
226 Transfer complete.
231190 bytes received in 0.01 secs (16026.9 kB/s)
ftp> bye
221 Goodbye.
linux@tuxworld:/tmp$ ls -l ubuntu.jpg 
-rw-rw-r-- 1 linux linux 231190 May 21 07:58 ubuntu.jpg
linux@tuxworld:/tmp$ 

Open the web browser in url type, ftp://ipaddress-of-ftp-server. Give system username and password and now you can download the files.

ftp3

ftp4

Read Some More Articles

2 Comments

  1. root@Lexington:~# cp -p vsftpd.conf.dpkg-new vsftpd.conf
    cp: cannot stat `vsftpd.conf.dpkg-new’: No such file or directory

    why? I cut & pasted all these lines?

    1. Hello Neil,

      Thanks for reporting the issue.
      I did a typo in doc.In my case, the vsftpd.conf.dpkg-new file was created in /etc/ after I install new vsftpd package.
      But you can also directly create /etc/vsftpd.conf file.
      Just paste the given below contents and restart the vsftpd service

      listen=YES
      anonymous_enable=NO
      local_enable=YES
      write_enable=YES
      dirmessage_enable=YES
      use_localtime=YES
      xferlog_enable=YES
      connect_from_port_20=YES
      secure_chroot_dir=/var/run/vsftpd/empty
      pam_service_name=vsftpd
      rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
      rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
      

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.