Recently I have been involved in doing to some source code compilation on an AWS EC2 instance. However, after the compilation I encountered a problem. I had difficulty transferring the generated output from the EC2 to the local Windows machine. Following my usual habit, I tried using a Filezilla client to connect to the EC2 instance but it didn’t work. After a lot of faff around I got it working. I decided to put together the steps I followed in a blog post. It may help someone, or even myself, in the future. Hence this blog.

You have likely created your own EC2 instance. The only thing you are trying to do is connect to it using a file transfer client. In this case I will only discuss about Filezilla because that is my favourite client.

I have used a Ubuntu 22.04 image for my EC2 instance. So my instructions will be based on that.

Security Group

First thing make sure you have the following added in your security group of the EC2 instance:

If not then add them following the below steps:

Click on the Edit inbound rules.

Now, click on the Add Rule button:

And add the below highlighted rules:

Click on the Save rules. Now, your Amazon EC2 is ready to accept ssh connections.

Installation of vsftpd

Next we need to install vsftpd (very secure file transfer protocol deamon) in our EC2 instance. On the Ubuntu command prompt please do the following:

ubuntu@ip-172-31-33-111:~/workspace/source/SSB-buildroot$ sudo apt-get install vsftpd

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
ssl-cert
The following NEW packages will be installed:
ssl-cert vsftpd
0 upgraded, 2 newly installed, 0 to remove and 68 not upgraded.
Need to get 140 kB of archives.
After this operation, 391 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Press Y and enter. The vsftpd daemon should be installed without any problem. However, if you see the following screen, press Tab and click/enter Ok (just ignore for the time being):

Modify the vsftp config

Now we need to do a few modifications on the vsftpd config file. Open the following file in super user mode:

sudo vim /etc/vsftpd.conf

Enable listen (change NO to YES):

listen=YES

If anonymous_enable is set to YES, change it to NO (we don’t want anonymous user to access our EC2 istance!).

Change write_enable to YES

If connect_from_port_20 is not set to YES, please change it to YES.

connect_from_port_20=YES

Then finally add the following lines in at the very bottom of the config file:

pasv_enable=YES
pasv_min_port=1024
pasv_max_port=1048
pasv_address=13.40.82.253
port_enable=YES
userlist_enable=YES
userlist_file=/etc/vsftpd.userlist
userlist_deny=NO

pasv_address is your Ubuntu EC2 public IP. Do not give it away like me. I am putting it here just to avoid any confusion and I am going to destroy my EC2 instance pretty soon after this post 😀

You may like to add a new user. But in my case I didn’t create any new user other than the default Ubuntu user “ubuntu”.

The users are enlisted in the following file:

/etc/vsftpd.userlist

You maylike to check your username in this list like the below:

ubuntu@ip-172-31-33-111:~/workspace/source/SSB-buildroot$ echo "vbhadra" | sudo tee -a /etc/vsftpd.userlist

vbhadra

vbhadra is my username

Restart the vsftpd service

Now the vsftpd daemon is all set to go. We just need to restart the daemon once and all should be good. Restart the daemon using the following command:

sudo service vsftpd start

Filezilla Configurations

Now we are good with the EC2 side of settings and configurations. Time to focus on our Filezilla. Launch Filezilla application. Then go to Edit and click on Settings. You should see a window like the below:

Click on SFTP as we have to do few bit on this particular configuration option. Now, before we make further progress we need to think about a bit about public and private keys. While creating the EC2 instance you must have used an existing

Leave a Reply

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