DWQA QuestionsHow to Installing ftp server on an ubuntu ec2 instance?
kandy asked 3 years ago

Installing ftp server on an ubuntu ec2 instance

So we recently had this requirement to give ftp access to a third party client on our staging server. They did not want the hassle of sshing in and making changes or committing changes to git and then making the changes live. Now, installing an ftp with a username-password access might seem like a daunting task initially, but here is how I managed to do it.
Step 1 : Installing vsftpd server
vsftpd ( very secure ftp daemon ) is one of the popular ftp servers out there. After logging in to the ec2 instance, the following command will install vsftpd
sudo apt-get install vsftpd
Step 2 : Make the following changes to the vsftpd conf file 
The configuration file can be opened up for editing at
sudo vim /etc/vsftpd/vsftpd.conf
And change/add the following flags:
anonymous_enable=NO
write_enable=YES
local_enable=YES
pasv_enable=YES
pasv_min_port=13000
pasv_max_port=13100
port_enable=YES
pasv_address=[public dns from the amazon EC2 instance] pasv_addr_resolve=YES

After doing the above, we need to boost up or daemon again.
sudo service vsftpd restart
Step 3 : Opening up port from the ec2 dashboard
Hop on to aws.amazon.com, login and go to your ec2 dashboard. Over there, for our particular instance, check the security group that it is a part of. Then hop on to that security group section and edit the rules of that particular security group as follows :

Notice that I’ve added the “All TCP” rule which will open up a range of ports for connection. Also note that we did not have a very strict security requirement, but if you are looking for that, then I would recommend opening up selective ports only.
Step 4 : Create a user and make him owner of the root directory
In the ec2 instance console, just add a new user by
sudo adduser ftpuser
It will prompt you to enter details including the password. After we are done with that, we need to make this user the owner of the directory which we want him to be able to read/write. In my case it was the document root for apache, hence the following command :
sudo chown -R ftpuser:ftpuser /var/www/html/