site logo
search logo

Channel

Your Details



Contact Us

Blog

How to Configure FTP on an EC2 Instance

A vsftpd daemon on an EC2 Linux instance is installed through following steps: Installing the daemon, configuring the ‘.conf ‘ file, setting up a User & giving it the required permission to connect it through Filezilla to transfer files between local host & instance.

How to Configure FTP on an EC2 Instance

FTP


FTP  (File Transfer Protocol) is a standard network protocol used for the transfer of computer files between a client and server on a computer network or between hosts over the internet. It is commonly used as a method to upload or download files to or from a site quickly. FTP clients allow connections from both anonymous and registered users. When the goal is to limit who can perform the file transfer, the login is often set up to require a username and password.



Steps to configure FTP on an AWS Linux (Ubuntu 18) EC2 instance:


  1. A Ubuntu 18 EC2 instance is required in AWS with SSH root access i.e on the SG, SSH (port 22) should be allowed to access.






The running instance.



  1. After SSH logging to your EC2 instance, you have to run the following commands in order to install vsftpd.



  • You have to start by updating the  package list and installing the vsftpd daemon


sudo apt update


sudo apt install vsftpd





  • You’ll copy the configuration file so that you can start with a blank configuration, saving the original as a backup, to get it handy, if anything goes wrong.


sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig

  • You ‘ll have to set- up a new User Directory

you’ll add a test user

sudo adduser ftpuser

You ‘ll have to assign a password when prompted and can feel free to press “ENTER”

through the other prompts.

Next you have to create user directory

sudo mkdir /home/ftpuser/ftp

sudo chown nobody:nogroup /home/ftpuser/ftp

sudo chmod a-w /home/ftpuser/ftp

 

 

  • You‘ll have to verify the permissions


sudo ls -la /home/ftpuser/ftp



  • You’ll have to create the directory where files can be uploaded and assign ownership to the user


sudo mkdir /home/ftpuser/ftp/files


sudo chown ftpuser:ftpuser /home/ftpuser/ftp/files


sudo ls -la /home/ftpuser/ftp





You can just add a Test file to use when you can test later on


echo "vsftpd test file" | sudo tee /home/ftpuser/ftp/files/test.txt



  • You can plan to allow a single user with a local shell account to connect with FTP. The two key settings for this are already set in “vsftpd.conf”. You can start by opening the config file to verify the settings in your configuration.


sudo nano /etc/vsftpd.conf


You have to change the following:


# Allow anonymous FTP? (Disabled by default).

anonymous_enable=NO


# Uncomment this to allow local users to log in.

local_enable=YES


write_enable=YES


chroot_local_user=YES


user_sub_token=$USER

local_root=/home/$USER/ftp


pasv_min_port=40000

pasv_max_port=50000


userlist_enable=YES

userlist_file=/etc/vsftpd.userlist

userlist_deny=NO



  • Afterwards, you will have to create and add your user to the file. You will use the -a flag

to append to file.

echo "ftpuser" | sudo tee -a /etc/vsftpd.userlist

 

  • You have to restart the daemon to load the configuration changes.

sudo systemctl restart vsftpd

Here are the following screenshots:

 

Finally you can go to Filezilla for File transfer:


Get our hottest stories delivered to your inbox.

Sign up for Scrabbl Newsletters to get personalized updates on top stories and viral hits.