aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • Engineering

How-To: Install and configure FTPs Server on Ubuntu 22.04

  • aster.cloud
  • September 23, 2022
  • 5 minute read

This guide will show you how to install and configure an FTP(s) or SFTP server on a Ubuntu machine.

Prerequisites

  • Operating System of (s)FTP server : Ubuntu 22.04

Step 01: Installation

01. Update the system package resources


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

$ sudo apt update

02. Install the SFTP package

$ sudo apt install vsftpd -y

03. Verify that Very Secure FTP  (VSFTP) has been installed by checking the version.

$ vsftpd -version

04. Install Firewalld

$ sudo apt install firewalld

05. Start the service if it is stopped.

$ sudo systemctl start vsftpd

06. Set the service to automatically start on boot

$ sudo systemctl enable vsftpd

07. Create the firewall rules to allow FTP traffic on Port 20, 21 and 22..

$ sudo ufw allow 20/tcp
$ sudo ufw allow 21/tcp
$ sudo ufw allow 22/tcp

 

Check the firewall status. It should be “inactive”

$ sudo ufw status

08. Enable the firewall service. Accept the changes by confirming with “y”.

$ sudo ufw enable

Check again that the firewall is active.

$ sudo ufw status

Step 02: Configuration

01. Backup the original version of the VSFTP configuration

$ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.original

02. Edit the configuration file

$ sudo nano /etc/vsftpd.conf

03. For FTP access for registered users. Applicable for registered Users with Password or SSH (or SFTP).

anonymous_enable NO When enabled non-registered users will be able to access the FTP service. Set the value as “NO” to not allow anonymous access.
local_enable YES Default value: YES. Set value as “YES”. 
write_enable Value: YES Uncomment this setting. Set value as “YES”
chroot_local_user Value: YES Uncomment this setting. This limits the FTP users to their own directory. Set value as “YES”
chroot_list_file Value: /etc/vsftpd.chroot_list Uncomment this setting and set the value as “/etc/vsftpd/chroot_list”.

Add the following configurations at the bottom.

...
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

04. Restart the service to apply the changes

$ sudo systemctl restart vsftpd

05. Check the status of the service to see if there are errors.

$ sudo systemctl status vsftpd

Step 03: Configuration – SSL / FTPS

To secure the FTP with SSL/TLS certificate use the following steps. Note that if SSL is configured, only SFTP or registered users with SSH keys configured will be allowed.

Read More  Coding with Serenade: Hands-Free Voice-Activated Programming

Also note that you can also provide or install your own/bought SSL certificate. In this example we will be creating a self-signed certificate.

01. Create the directory to place the SSL file if it does not exist. By default this exists.

$ sudo mkdir /etc/ssl/private/

02. Create a new certificate or ignore this and install/copy your own certificate. You will be asked for details on the SSL, this is also a standard process if you bought an SSL certificate.

Prepare the following details before executing the next command.

  • Country Name (2 letter code)
  • State or Province Name (full name)
  • Locality Name (e.g. City)
  • Organization Name (eg, company)
  • Organizational Unit Name (eg, section)
  • Common Name (e.g. server FQDN or YOUR name)
  • Email Address
$ sudo openssl req -x509 -nodes -keyout /etc/ssl/private/vsftpd-selfsigned.pem -out /etc/ssl/private/vsftpd-selfsigned.pem -days 365 -newkey rsa:2048

Explanation for the parameters used

  • req – is a command for X.509 Certificate Signing Request (CSR) management.
  • x509 – means X.509 certificate data management.
  • days –  validity for the certificate, number of days before it expires
  • newkey – flag saying this is a new key
  • rsa:2048 – RSA key processor, will generate a 2048 bit private key
  • keyout – sets the key storage file
  • out – sets the certificate storage file

03. Open the VSFTP configuration for editing

$ sudo nano /etc/vsftpd.conf

04. Add the following at the end of the file

# SSL configuration (TLS v1.2)
ssl_enable=YES

#ssl_tlsv1_2=YES
ssl_sslv2=NO
ssl_sslv3=NO

# configure the location of the SSL certificate and key file
rsa_cert_file=/etc/ssl/private/vsftpd-selfsigned.pem
rsa_private_key_file=/etc/ssl/private/vsftpd-selfsigned.pem

# prevent anonymous users from using SSL
allow_anon_ssl=NO 

# force all non-anonymous logins to use SSL for data transfer
force_local_data_ssl=YES 

# force all non-anonymous logins to use SSL to send passwords
force_local_logins_ssl=YES 

# Select the SSL ciphers VSFTPD will permit for encrypted SSL connections with the ssl_ciphers option.
ssl_ciphers=HIGH 

# turn off SSL reuse
require_ssl_reuse=NO
pasv_min_port=40001
pasv_max_port=40100

05. Restart the service to apply the changes

$ sudo systemctl restart vsftpd

06. Check the status of the service to see if there are errors.

$ sudo systemctl status vsftpd

If you try to access the FTP server when using a client that does not use encryption. You will get the following message. Solution for this is to use an account with SFTP (User with SSH key) or FileZilla.

Read More  Top Recommendations For Building Real-Time Intelligence On Google Cloud

If there is a connection timeout, make sure that the server allows access on Port 21. Port 21 is the default FTP port.

Step 04: Adding an FTP User

01. Create a new FTP user.  In this example we will be using sysad.

Note that using SSH requires the SSH service running.

// FORMAT
$ sudo adduser {{username}} --disabled-password

// EXAMPLE
$ sudo adduser sysad --disabled-password

 

Switch to the new user

// FORMAT
$ sudo su - {{username}}

// EXAMPLE
$ sudo su - sysad

Create SSH directory and update the permissions

$ cd ~$ mkdir .ssh$ chmod 700 .ssh$ nano .ssh/authorized_keys

02. Set the content of the file with the public key of the user. It should contain something like. You can generate new key using online tools like.

ssh-rsa ...... 

Ctrl+O then Enter to save the changes. Then exit using Ctrl + X.

03. Update the permission of the authorised key

$ chmod 600 .ssh/authorized_keys

04. Exit from the user session.

$ exit

05. Restart the SSH service

$ sudo service sshd restart

06. Add a new user to the list FTP users.

# FORMAT
$ echo {{username}} | sudo tee –a /etc/vsftpd.user_list

# EXAMPLE
$ echo sysad | sudo tee –a /etc/vsftpd.user_list

07. Create the directory for the new user, and update the permissions. The following is only a sample structure for the user. Depending on the directory structure is designed the steps may be different. It will also disable accessing of the user directories from other users.

// FORMAT
$ sudo mkdir –p /home/{{username}}/ftp/upload
$ sudo chmod 550 /home/{{username}}/ftp
$ sudo chmod 750 /home/{{username}}/ftp/upload
$ sudo chown –R {{username}}: /home/{{username}}/ftp

// EXAMPLE
$ sudo mkdir -p /home/sysad/ftp/upload
$ sudo chmod 550 /home/sysad/ftp
$ sudo chmod 750 /home/sysad/ftp/upload
$ sudo chown -R sysad: /home/sysad/ftp

08. Create or update the chroot user list. These are the users who are “jailed”, meaning they can only access their own folders.

$ sudo nano /etc/vsftpd.chroot_list

Add the user to the file

// FORMAT
{{username}}

// EXAMPLE
sysad

Save the changes and exit from the nano editor.

Read More  How To Avoid Cloud Misconfigurations And Move Towards Continuous Compliance

09. Restart the service to apply the changes

$ sudo systemctl restart vsftpd

Step 05: Accessing the FTP Server

Registered User with SSH key

01. Add the Private key to the SSH session. This is the key generated on Step 04 #3.

// FORMAT
$ ssh-add {{private-ssh-key}}

// EXAMPLE
$ ssh-add sysad_key.private

If there is an error saying “Could not open a connection to your authentication agent.” and you know that SSH is installed, the SSH agent needs to be started/restarted.

$ eval `ssh-agent -s`

Then try again with the ssh-add command.

02. Login via SFTP. Accept the fingerprint confirmation the first time this command is executed.

// FORMAT
$ sftp {{username}}@{{hostname-or-ip-address}}

// EXAMPLE
$ sftp [email protected]

03. To list the files and folders of the current working directory.

$ ls -l

Removing an FTP User

01. Access the server and execute the following command to remove the user. Add an “-r” before the username to remove the user files.

# FORMAT
$ sudo userdel {{username}}

# EXAMPLE
$ sudo userdel sysad

Remove also the user file.

# FORMAT
$ sudo userdel {{username}} -r

# EXAMPLE
$ sudo userdel sysad -r

For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

aster.cloud

Related Topics
  • FTP
  • FTPs
  • sFTP
  • Tutorials
  • Ubuntu
  • Ubuntu 22.04
You May Also Like
View Post
  • Engineering
  • Technology

Guide: Our top four AI Hypercomputer use cases, reference architectures and tutorials

  • March 9, 2025
View Post
  • Computing
  • Engineering

Why a decades old architecture decision is impeding the power of AI computing

  • February 19, 2025
View Post
  • Engineering
  • Software Engineering

This Month in Julia World

  • January 17, 2025
View Post
  • Engineering
  • Software Engineering

Google Summer of Code 2025 is here!

  • January 17, 2025
View Post
  • Data
  • Engineering

Hiding in Plain Site: Attackers Sneaking Malware into Images on Websites

  • January 16, 2025
View Post
  • Computing
  • Design
  • Engineering
  • Technology

Here’s why it’s important to build long-term cryptographic resilience

  • December 24, 2024
IBM and Ferrari Premium Partner
View Post
  • Data
  • Engineering

IBM Selected as Official Fan Engagement and Data Analytics Partner for Scuderia Ferrari HP

  • November 7, 2024
View Post
  • Engineering

Transforming the Developer Experience for Every Engineering Role

  • July 14, 2024

Stay Connected!
LATEST
  • college-of-cardinals-2025 1
    The Definitive Who’s Who of the 2025 Papal Conclave
    • May 7, 2025
  • conclave-poster-black-smoke 2
    The World Is Revalidating Itself
    • May 6, 2025
  • 3
    Conclave: How A New Pope Is Chosen
    • April 25, 2025
  • Getting things done makes her feel amazing 4
    Nurturing Minds in the Digital Revolution
    • April 25, 2025
  • 5
    AI is automating our jobs – but values need to change if we are to be liberated by it
    • April 17, 2025
  • 6
    Canonical Releases Ubuntu 25.04 Plucky Puffin
    • April 17, 2025
  • 7
    United States Army Enterprise Cloud Management Agency Expands its Oracle Defense Cloud Services
    • April 15, 2025
  • 8
    Tokyo Electron and IBM Renew Collaboration for Advanced Semiconductor Technology
    • April 2, 2025
  • 9
    IBM Accelerates Momentum in the as a Service Space with Growing Portfolio of Tools Simplifying Infrastructure Management
    • March 27, 2025
  • 10
    Tariffs, Trump, and Other Things That Start With T – They’re Not The Problem, It’s How We Use Them
    • March 25, 2025
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    IBM contributes key open-source projects to Linux Foundation to advance AI community participation
    • March 22, 2025
  • 2
    Co-op mode: New partners driving the future of gaming with AI
    • March 22, 2025
  • 3
    Mitsubishi Motors Canada Launches AI-Powered “Intelligent Companion” to Transform the 2025 Outlander Buying Experience
    • March 10, 2025
  • PiPiPi 4
    The Unexpected Pi-Fect Deals This March 14
    • March 13, 2025
  • Nintendo Switch Deals on Amazon 5
    10 Physical Nintendo Switch Game Deals on MAR10 Day!
    • March 9, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.