How to setup FTP server on ubuntu 14.04 ( VSFTPD )

FTP is used to transfer files from one host to another over TCP network. This article explains how to setup FTP server on ubuntu 14.04 .
There are 3 popular FTP server packages available PureFTPD, VsFTPD and ProFTPD. Here i’ve used VsFTPD which is lightweight and less Vulnerability.

Setup FTP server on Ubuntu 14.04

Step 1 » Update repositories .
krizna@leela:~$ sudo apt-get update
Step 2 » Install VsFTPD package using the below command.
krizna@leela:~$ sudo apt-get install vsftpd
Step 3 » After installation open /etc/vsftpd.conf file and make changes as follows.
Uncomment the below lines (line no:29 and 33).
» Uncomment the below line (line no: 120 ) to prevent access to the other folders outside the Home directory.
chroot_local_user=YES and add the following line at the end.
allow_writeable_chroot=YES» Add the following lines to enable passive mode.

Step 4 » Restart vsftpd service using the below command.
krizna@leela:~$ sudo service vsftpd restart
Step 5 » Now ftp server will listen on port 21. Create user with the below command.Use /usr/sbin/nologin shell to prevent access to the bash shell for the ftp users .
krizna@leela:~$ sudo useradd -m john -s /usr/sbin/nologin
krizna@leela:~$ sudo passwd john

Step 6 » Allow login access for nologin shell . Open /etc/shells and add the following line at the end.
Now try to connect this ftp server with the username on port 21 using winscp or filezilla client and make sure that user cannot access the other folders outside the home directory.
setup FTP server ubuntu 14.04
Please note using ftp on port 21 is a big security risk . it’s highly recommended to use SFTP. Please continue for SFTP configuration

Secure FTP ( SFTP )

SFTP is called as “Secure FTP” which generally use SSH File Transfer Protocol . so we need openssh-server package installed , Issue the below command if it’s not already installed.
krizna@leela:~$ sudo apt-get install openssh-server
Step 7 » Create a new group ftpaccess for FTP users.
krizna@leela:~$ sudo groupadd ftpaccess
Step 8 » Now make changes in this /etc/ssh/sshd_config file.
» Find and comment the below line
Subsystem sftp /usr/lib/openssh/sftp-server and Add these lines at the end of the file.
Subsystem sftp internal-sftp
Match group ftpaccess
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

Step 9 » Restart sshd service.
krizna@leela:~$ sudo service ssh restart
Step 10 » The below steps must be followed while creating Users for sftp access.
Create user john with ftpaccess group and /usr/bin/nologin shell.
krizna@leela:~$ sudo useradd -m john -g ftpaccess -s /usr/sbin/nologin
krizna@leela:~$ sudo passwd john
Change ownership for the home directory.
krizna@leela:~$ sudo chown root /home/johnCreate a folder inside home directory for writing and change ownership of that folder.
krizna@leela:~$ sudo mkdir /home/john/www
krizna@leela:~$ sudo chown john:ftpaccess /home/john/www

Now try to connect server using SFTP ( port : 22 ) and makesure Users can upload files to www directory and cannot access other folders outside home directory.setup FTP server ubuntu 14.04
If you want use both FTP and SFTP together, please perform above steps ( Step 10 ) while creating users . For existing users, move them to ftpaccess group and create folder structure and ownership changes as below.
krizna@leela:~$ sudo usermod john -g ftpaccess -s /usr/sbin/nologin
krizna@leela:~$ sudo chown root /home/john
krizna@leela:~$ sudo mkdir /home/john/www
krizna@leela:~$ sudo chown john:ftpaccess /home/john/www

Now john can able to upload files to www folder using FTP as well as SFTP.

Also see :
» Setup FTP server on ubuntu 16.04
» Setup FTP server on centos 7
» Configure ftp server on centos 6

All the best.


  1. Is it possible to create an SFTP user which can upload files to the “var/www/html” directory without accessing files and folders outside this directory?

    I’m new to this…

  2. After finishing all sftp steps:

    Server unexpectedly closed network connection
    Could not connect to server

    Edit: Problem solved.

  3. I tried the steps mentioned above to set up FTP server in my ubuntu laptop. However the filezilla test only works on my local PC. When I tried to access from outside my network using Filezilla, the connection doesn’t get established. What am I missing here?

    • I didn’t see any problems here , I’ve followed the steps on ubuntu and debian6 hosted on digital ocean nearly 10 servers and works as expected . Can you explain what kinda problems you faced ?

  4. Could not chdir to home directory /home/jhon: No such file or directory

    This service allows sftp connections only.

  5. Hi, I am able to view the /home/username folder via SFTP but I am unable to make any changes or transfer file. Can you please help?

  6. I have setup an ftp server in ubuntu. I am having access to my ftpserver. What i need right now is i need to unzip files in my ftpserver using ssh connection. (there is unzip command in ssh). How can i do this in C program? Thanks in advance

  7. hii.. i already follow all the steps.. everything was fine, but after i give permission to sub folder /var/www/html using chown, i got error connection timed out and i can’t even access my server anymore.. anybody get same problem

  8. Dear tutorial makers. Please start providing any and all requirements along with keeping your shit up to date. Thanks very fucking much!

  9. My users are comming in the map /var/www/

    But as user martinmeijer i can see the domain map of an other user…

    How can i make it work that users only see their maps and not from other users

    I hope you understand what i mean

6 Trackbacks / Pingbacks

  1. AWS EC2에 vsftpd 설치 | Design Arete 디자인아레테
  2. Unix/Linux:Does vsftpd support plain FTP? – Unix Questions
  3. Unix/Linux:Restrict SFTP users to different directories – Unix Questions
  4. AWS connection error: Permission denied (publickey) – segmentfault
  5. [ASK] server - SFTP chroot to /var/www stopped working | Some Piece of Information
  6. Setup FTP server on centos 7 ( VSFTP )

Leave a Reply

Your email address will not be published.