Technoracle
    Facebook Twitter Instagram
    • Sitemap
    • Privacy Policy
    • Disclaimer
    • Term of Services
    Facebook Twitter Instagram Pinterest Vimeo
    TechnoracleTechnoracle
    • Tutorials
      • Amazon Cloud
      • Google Cloud
    • How To
    • Blog
    • About
    Subscribe
    Technoracle
    Home»How To»How To Setup FTP on AWS EC2 Ubuntu Instance
    How To

    How To Setup FTP on AWS EC2 Ubuntu Instance

    Rajesh ShivamBy Rajesh ShivamJune 3, 2022Updated:June 3, 2022No Comments3 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Setup FTP on AWS EC2 Ubuntu
    Share
    Facebook Twitter LinkedIn Pinterest Email
    Setup FTP on AWS EC2 Ubuntu
    FTP installation on AWS EC2 instance

    Accessing the EC2 Ubuntu server for files upload or download is very complex for end users because it has no Cpanel or user interface installed within, so to upload/download any data to the EC2 server. In this article, I have explained step by step tutorial to setup FTP on AWS EC2 Ubuntu 20.04.

    Page Contents

    • FTP Setup in Amazon EC2 instance Ubuntu 20.04
      • Step 1 : Install vsftpd
      • Step 2 : Firewall Configuration
      • Step 3 : User Creation
      • Step 4: Access Rights
      • Step 5: FTP server configuration
    • Conclusion

    FTP Setup in Amazon EC2 instance Ubuntu 20.04

    Step 1 : Install vsftpd

    SSH to the AWS EC2 instance, here’s is how you can SSH to the EC2 instance.

    $ sudo apt install vsftpd
    $ sudo service vsftpd status
    Setup FTP on AWS EC2 Ubuntu

    Step 2 : Firewall Configuration

    In the security groups inbound rules, you have to add following rules.

    • Port 22 for SSH
    • 20 to 21 for insecure FTP
    • Port 12000 – 12100

    After adding this port to security group, now you have to check firewall status by following command

    $ sudo ufw status

    If it is show inactive, it’s okay. Now run following commands

    $ sudo ufw allow 20:21/tcp
    $ sudo ufw allow 12000:12100/tcp
    $ sudo ufw enable

    After firewall enable, check status again

    $ sudo ufw status

    It should be active now, and shows similar to the below.

    Install FTP on AWS EC2 Ubuntu

    Step 3 : User Creation

    Now you have to create user with proper access rights. Let’s create a user with user name programmer_1.

    $ sudo adduser programmer_1

    As we will share only FTP access to the user (programmer_1), we have to modify SSH configuration file to prevent SSH access from the FTP user.

    $ sudo vi /etc/ssh/sshd_config

    Add the following line to the file

    DenyUsers programmer_1

    Save the file and restart SSH service by following command

    $ sudo service sshd restart

    Step 4: Access Rights

    It completely depends upon the user rules, let’s give users only home directory access, what users will upload, update or download files there. I will create a home directory for the FTP user.

    $ sudo mkdir /home/programmer_1/ftp_files

    Now, set ownership of the newly created directory of the FTP user.

    $ sudo chown nobody:nogroup /home/programmer_1/ftp_files

    Added some more permission

    $ sudo chmod a-w /home/programmer_1/ftp_files
    • a-w means – all/everyone remove write permissions. Read more about Linux permissions

    Now we will create sub directory where FTP user will upload the files with ownership assign

    $ sudo mkdir /home/programmer_1/ftp_files/uploads
    $ sudo chown programmer_1:programmer_1 /home/programmer_1/ftp_files/uploads

    Step 5: FTP server configuration

    Before configuring the vsftpd configuration file located in /etc/vsftpd, take a backup of the file.

    $ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
    $ sudo vi /etc/vsftpd.conf

    Now, change the pasv_address=x. x. x. x with the IP address of the EC2 Instance and listen=YES to remove the warning message from the FTP client.

    listen=YES
    listen_ipv6=NO
    write_enable=YES
    chroot_local_user=YES
    local_umask=022
    force_dot_files=YES
    
    pasv_enable=YES
    pasv_min_port=12000
    pasv_max_port=12100
    port_enable=YES
    
    pasv_address=x.x.x.x
    user_sub_token=$USER
    local_root=/home/$USER/ftp

    Now, restart the FTP server to make sure everything running perfectly with following commands.

    $ sudo systemctl restart vsftpd
    $ sudo service vsftpd status

    If all working fine, you should see following.

    ● vsftpd.service - vsftpd FTP server
       Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2020-03-26 04:16:27 UTC; 3s ago
      Process: 26682 ExecStartPre=/bin/mkdir -p /var/run/vsftpd/empty (code=exited, status=0/SUCCESS)
     Main PID: 26693 (vsftpd)
        Tasks: 1 (limit: 1152)
       CGroup: /system.slice/vsftpd.service
               └─26693 /usr/sbin/vsftpd /etc/vsftpd.conf

    Now, you can login with your FTP client such as filezilla or any other.

    Conclusion

    In this guide, you learned how to configure FTP on Amazon EC2 Server. If you are new to AWS and wondering about LAMP installation, here is the guide. If you have any questions, feel free to comment, I will answer all your questions.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to Host Multiple Websites on Single AWS EC2 Instance
    Next Article Updated VI Keyboard Shortcuts – Make Your Command Line Super Friendly [PDF Cheatsheet]
    Rajesh Shivam

    Hello, everyone, I am Rajesh Shivam, I am a full-time freelancer with more than seven years plus experience in different freelancing platforms, in this blog, I am going to provide complete freelancing tips and tricks.

    Related Posts

    How To

    How to Install Microsoft Teams on Ubuntu 22.04 Easily

    February 22, 2023
    Read More
    How To

    What is Elastic IP and Its Pricing in AWS

    February 22, 2023
    Read More
    How To

    How to Convert PEM to PPK file [Step by Step Guide]

    February 22, 2023
    Read More
    Add A Comment

    Leave A Reply Cancel Reply

    Facebook Twitter Instagram Pinterest
    © 2023 Technoracle

    Type above and press Enter to search. Press Esc to cancel.

    Go to mobile version