Grid Guides

Explore How System On Grid Can Work For You

Grid Guide Topics

How to Setup FTP Server on Ubuntu 18.04

Table Of Contents


    ## Table of Contents

    – [Introduction](#introduction
    – [Prerequisites](#prerequisites
    – [VSFTPD Installation](#vsftpd-installation
    – [Configure FSFTPD Server](#configure-fsftpd-server
    – [Create FTP User](#create-ftp-user
    – [Connect to FTP Server](#connect-to-ftp-server
    – [Conclusion](#conclusion

    ## Introduction

    [FTP](https://en.wikipedia.org/wiki/File_Transfer_Protocol is a standard network protocol used for transfer of computer files between a client and server on Computer network. It is built on a client-server model architecture using separate control and data connections between the client and server.

    ## Prerequisites

    Privileged access to the system as root or a non-root user account with sudo privileges is required. Create a non-root user account with sudo privileges by following our guide, [Initial server setup with Ubuntu 18.04](https://systemongrid.com/guides/how-to-do-initial-server-setup-with-ubuntu-18.04.

    ## VSFTPD Installation

    First of all, you have to install VSFTPD Thread. To do this you have to open the terminal and enter the below command.
    “`
    $ sudo apt-get install vsftpd
    “`
    Now it is installed. Next step is to configure the VSFTPD.

    ## Configure FSFTPD Server

    Before configuring FSFTPD server, you have to take a backup for current server configuration file:
    “`
    $ sudo mv /etc/vsftpd.conf /etc/vsftpd.conf_orig
    “`
    Now you have to create a new configuration file /etc/vsftpd.conf using text editor as shown below
    “`
    $ sudo nano /etc/vsftpd.conf
    “`
    Now you have to start basic FTP server configuration, and make sure that it is working and after assuring that it suited to all environments.
    “`
    listen=NO
    listen_ipv6=YES
    anonymous_enable=NO
    local_enable=YES
    write_enable=YES
    local_umask=022
    dirmessage_enable=YES
    use_localtime=YES
    xferlog_enable=YES
    connect_from_port_20=YES
    chroot_local_user=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
    ssl_enable=NO
    pasv_enable=Yes
    pasv_min_port=10000
    pasv_max_port=10100
    allow_writeable_chroot=YES
    “`
    Add this FTP configuration lines to /etc/vsftpd.conf file.

    ![ftpconffile](https://grid.media/assets/images/ftp-conf-file.png

    If your UFW firewall is enabled then execute the below command to allow traffic to FTP ports.
    “`
    $ sudo ufw allow from any to any port 20,21,10000:10100 proto tcp
    “`
    Now it is done. Now you have to restart VSFTPD server to apply new changes.
    To do this use below command.
    “`
    $ sudo service vsftpd restart
    “`
    ## Create FTP User

    Now we have to create FTP user. If you want to create a new system account i.e. ftpuser then use the below script.
    “`
    $ sudo useradd -m ftpuser
    $ sudo passwd ftpuser
    “`

    ![addftpuser](https://grid.media/assets/images/add-ftp-user.png

    To test it create an arbitrary file within ftpuser ‘s home directory. If you log in you can able to see and edit this file.
    “`
    $ sudo bash -c “echo FTP TESTING > /home/ftpuser/FTP-TEST”
    “`
    Now your FTP server configuration is over. If you want to use FTP on any other network than your local network, then it is better to configure SFTP server to add security to your FTP connections.

    ## Connect to FTP Server
    So far you are ready to use ftpuser to connect and login to your new FTP server. As of now your new FTP server can be resolved through hostname ubuntu-ftp now you can use ftp command for login:
    “`
    $ ftp testftp
    “`

    ![testftp](https://grid.media/assets/images/testftp.png

    ## Conclusion
    Now we have described FTP configuration.