25th Anniversary Savings | 25% Off Dedicated Servers*Shop Now
25th Anniversary Savings | 25% Off VPS Hosting* †††Shop Now
Limited Inventory: High-Performance AMD-Powered Servers Now Available.* Shop Now >

How to Create an FTP Server and Account in AlmaLinux

Posted on by Mohammed Noufal | Updated:
Reading Time: 7 minutes

The file transfer protocol (FTP) and secure file transfer protocol (SFTP) or SSH File Transfer Protocol are popular protocols that are used to download files from a remote or local server or upload files onto the server.

FTP is not recommended for connections over the internet because it relies on plain text passwords for authentication and does not use encryption. SFTP is usable instead of FTP since it tunnels the FTP protocol through SSH, providing the encryption needed to establish a secure connection.

This article provides step-by-step instructions to create an FTP server and account through VSFTP software or an SFTP server through OpenSSH on AlmaLinux.

Requirements

  • Operating system and version : AlmaLinux OS 8.5
  • Processor : 1.1 GHz
  • RAM: Minimum: 1 GB but recommended: 2 GB
  • Disk Space: Minimum: 20 GB but recommended: 40 GB
  • Architecture : 64-bit
  • Software: VSFTPD and OpenSSH
  • Root privileged access to your Linux system or via the sudo command.
  • Root privileges to execute Linux commands either directly as a root user or by use of sudo command

How to Create an FTP Server and Account in AlmaLinux

Step 1: VSFTPD installation

VSFTPD is a secure and fast FTP server for Unix-based operating systems. To install VSFTPD on your system, run the following command into the terminal.

sudo dnf install vsftpd

Here is the output.

[root@noufserver ~]# sudo dnf install vsftpd
AlmaLinux 8 - BaseOS                                                                                                                     8.0 MB/s | 5.9 MB     00:00    
AlmaLinux 8 - AppStream                                                                                                                   17 MB/s | 9.4 MB     00:00    
AlmaLinux 8 - Extras                                                                                                                      54 kB/s |  12 kB     00:00    
Dependencies resolved.
=========================================================================================================================================================================
Package                               Architecture                          Version                                      Repository                                Size
=========================================================================================================================================================================
Installing:
 vsftpd                                x86_64                                3.0.3-34.el8                                 appstream                                180 k
Transaction Summary
=========================================================================================================================================================================
Install  1 Package
Total download size: 180 k
Installed size: 347 k
Is this ok [y/N]: y
Downloading Packages:
vsftpd-3.0.3-34.el8.x86_64.rpm                                                                                                           2.1 MB/s | 180 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    1.1 MB/s | 180 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                 1/1 
  Installing       : vsftpd-3.0.3-34.el8.x86_64                                                                                                                     1/1
  Running scriptlet: vsftpd-3.0.3-34.el8.x86_64                                                                                                                      1/1 
  Verifying        : vsftpd-3.0.3-34.el8.x86_64                                                                                                                      1/1 
Installed:
  vsftpd-3.0.3-34.el8.x86_64                                                                                                                                             
Complete!
[root@noufserver ~]#

Step 2: Configure VSFTPD Server

Create a backup copy of the original configuration file. To rename the default config file, you can run the following command.

[root@noufserver ~]# sudo mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf_original

Create a new VSFTPD configuration file using vi or the text editor you prefer.

[root@noufserver ~]# sudo vi /etc/vsftpd/vsftpd.conf

Add the following base configuration into the new VSFTPD configuration file. This configuration is for a basic FTP server. You can tweak the configuration as per your requirements.

anonymous_enable=NO
connect_from_port_20=YES
dirmessage_enable=YES
local_enable=YES
local_umask=022
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
write_enable=YES
xferlog_enable=YES
xferlog_std_format=YES

Save changes and close the file.

Using the cat command, confirm the contents of your file. Here is the output.

[root@noufserver ~]# cat /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
connect_from_port_20=YES
dirmessage_enable=YES
local_enable=YES
local_umask=022
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
write_enable=YES
xferlog_enable=YES
xferlog_std_format=YES

By default, Firewalld (AlmaLinux’s default firewall) will block FTP traffic. But you can create an exception to allow the traffic by using the following commands.

sudo firewall-cmd --zone=public --add-service=ftp --permanent

sudo firewall-cmd --reload

Here are the outputs.

[root@noufserver ~]# sudo firewall-cmd --zone=public --add-service=ftp --permanent
success
[root@noufserver ~]# sudo firewall-cmd --reload
success
[root@noufserver ~]#

Restart VSFTPD to apply the new changes with the following command.

[root@noufserver ~]# sudo systemctl restart vsftpd

Step 3: Create an FTP User

The FTP server is now ready to receive incoming connections. To connect to the FTP service, you will need to create a new FTP user account on your AlmaLinux server.

To create a new account called testftpuser, use the following command.

sudo useradd -m testftpuser

To set a password for the account, use the following command and then enter the desired password at the prompts.

sudo passwd testftpuser

Here is the output.

[root@noufserver ~]# sudo useradd -m testftpuser
[root@noufserver ~]# sudo passwd testftpuser
Changing password for user testftpuser.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

To verify the FTP service is working, you need to store a file in the created user's home directory. This file should be visible when you login to FTP.

Use the following command to create the file.

[root@noufserver ~]# sudo bash -c "echo TO CHECK WORKING OF FTP > /home/testftpuser/FTP_CHECK"

Step 4: Connect to FTP Server Via Command Line

Install the FTP command line utility by using the following command.

sudo dnf install ftp

Here is the output.

[root@noufserver ~]# sudo dnf install ftp
Last metadata expiration check: 0:36:08 ago on Sun 20 Feb 2022 04:57:08 AM UTC.
Dependencies resolved.
=========================================================================================================================================================================
 Package                             Architecture                           Version                                      Repository                                 Size
=========================================================================================================================================================================
Installing:
 ftp                                 x86_64                                 0.17-78.el8                                  appstream                                  70 k
Transaction Summary
=========================================================================================================================================================================
Install  1 Package
Total download size: 70 k
Installed size: 112 k
Is this ok [y/N]: y
Downloading Packages:
ftp-0.17-78.el8.x86_64.rpm                                                                                                               617 kB/s |  70 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    419 kB/s |  70 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                 1/1 
  Installing       : ftp-0.17-78.el8.x86_64                                                                                                                          1/1 
  Running scriptlet: ftp-0.17-78.el8.x86_64                                                                                                                          1/1 
  Verifying        : ftp-0.17-78.el8.x86_64                                                                                                                          1/1 
Installed:
  ftp-0.17-78.el8.x86_64                                                                                                                                                 
Complete!
[root@noufserver ~]#

You are now able to connect to the FTP server by using your IP address or hostname. 

To connect FTP from the command line and verify that everything is working, you will need to open a terminal and use the ftp command to connect to the loopback IP address (127.0.0.1).

Here is the command syntax and output.

[root@noufserver ~]# ftp 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
220 (vsFTPd 3.0.3)
Name (127.0.0.1:root): testftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls 
227 Entering Passive Mode (127,0,0,1,231,235).
150 Here comes the directory listing.
-rw-r--r--    1 0        0              24 Feb 20 05:31 FTP_CHECK
226 Directory send OK.
ftp> quit
221 Goodbye.
[root@noufserver ~]#

Step 5: Connect to FTP Server Via GNOME GUI

If you want to connect FTP server via a graphical user interface (GUI), you can use any of the FTP clients like FileZilla or the GNOME desktop on AlmaLinux. The GNOME desktop has the ability to connect to FTP servers from the file manager.

You can connect FTP via GNOME GUI on AlmaLinux by following the below steps: 

1. Open the File Manager from the Activities menu.

2. Click on Other Locations and enter ftp://127.0.0.1 in the Connect to Server box at the bottom of the window. Click the Connect button.

3. Enter the FTP account’s credentials that were created earlier and click the Connect button.

4. Once connected, you can find and use the test file you created earlier to ensure proper functionality.

Step 6: Setup an SFTP Server Through OpenSSH

OpenSSH is a suite of secure networking utilities based on the Secure Shell protocol, providing a secure connection over an unsecured network. If OpenSSH is already installed and enabled on AlmaLinux, you don’t need any additional software to run an SFTP server.

Use the following command to install OpenSSH if it’s not already installed on the server.

sudo dnf install openssh-server openssh-clients

Here is the output.

[root@noufserver ~]# sudo dnf install openssh-server openssh-clients
Last metadata expiration check: 0:00:49 ago on Sun 20 Feb 2022 09:59:23 AM UTC.
Dependencies resolved.
=========================================================================================================================================================================
 Package                                      Architecture                        Version                                      Repository                           Size
=========================================================================================================================================================================
Installing:
 openssh-clients                              x86_64                              8.0p1-10.el8                                 baseos                              667 k
 openssh-server                               x86_64                              8.0p1-10.el8                                 baseos                              484 k
Transaction Summary
=========================================================================================================================================================================
Install  2 Packages
Total download size: 1.1 M
Installed size: 3.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): openssh-server-8.0p1-10.el8.x86_64.rpm                                                                                            2.8 MB/s | 484 kB     00:00    
(2/2): openssh-clients-8.0p1-10.el8.x86_64.rpm                                                                                           3.5 MB/s | 667 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    5.1 MB/s | 1.1 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                 1/1 
  Running scriptlet: openssh-server-8.0p1-10.el8.x86_64                                                                                                              1/2 
  Installing       : openssh-server-8.0p1-10.el8.x86_64                                                                                                              1/2 
  Running scriptlet: openssh-server-8.0p1-10.el8.x86_64                                                                                                              1/2 
  Installing       : openssh-clients-8.0p1-10.el8.x86_64                                                                                                             2/2 
  Running scriptlet: openssh-clients-8.0p1-10.el8.x86_64                                                                                                             2/2 
  Verifying        : openssh-clients-8.0p1-10.el8.x86_64                                                                                                             1/2 
  Verifying        : openssh-server-8.0p1-10.el8.x86_64                                                                                                              2/2 
Installed:
openssh-clients-8.0p1-10.el8.x86_64                                                 openssh-server-8.0p1-10.el8.x86_64                                                
Complete!
[root@noufserver ~]#

Once OpenSSH is installed, you will need to make some changes to the SSHD configuration file. Use vi or your favorite text editor to open the file.

[root@noufserver ~]# sudo vi /etc/ssh/sshd_config

Add the following 5 lines at the bottom of the configuration file.

Match group sftp
ChrootDirectory /home
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

These lines allow users in the sftp group to access their home directories via SFTP and deny the users from normal SSH access so they can never access a shell. 

Save and close the configuration file.

Restart the SSH service so the new changes take effect. 

[root@noufserver ~]# sudo systemctl restart sshd

By default, Firewalld (AlmaLinux’s default firewall) will block SFTP/SSH traffic. But, you can create an exception to allow the traffic by using the following commands.

sudo firewall-cmd --zone=public --add-service=ssh --permanent

sudo firewall-cmd --reload

Here is the output.

[root@noufserver ~]# sudo firewall-cmd --zone=public --add-service=ssh --permanent
success
[root@noufserver ~]# sudo firewall-cmd --reload
success

Step 7: Create SFTP user account

If you wish to grant SFTP access to anyone, you can create SSH user accounts for them. 

Create a new user group. For this tutorial, the group is called sftpgroup. All of the SFTP users will need to belong to this group.

[root@noufserver ~]# sudo groupadd sftpgroup

Next, create a new user. The user for this tutorial is sftpuser and will be added to the sftpgroup group.

[root@noufserver ~]# sudo useradd -m sftpuser -g sftpgroup

Set a password for the newly-created user.

sudo passwd sftpuser

Here is the output.

[root@noufserver ~]# sudo passwd sftpuser
Changing password for user sftpuser.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

To grant full access to the user on their own home directory and deny access to the directory for all other users on the system, run the following command.

sudo chmod 700 /home/sftpuser/

Here is the output.

[root@noufserver ~]# sudo chmod 700 /home/sftpuser/
[root@noufserver ~]# ls -ld /home/sftpuser/
drwx------. 3 sftpuser sftpgroup 78 Feb 20 09:45 /home/sftpuser/
[root@noufserver ~]#

Step 8: Connect to SFTP server via command line

You can connect to the SFTP server via command-line using the hostname or IP address of your system. 

To test SFTP from the same system, you will need to open a terminal session and use the sftp command to connect to the loopback IP address 127.0.0.1.

sftp sftpuser@127.0.0.1

Here is the output.

[root@noufserver ~]# sftp sftpuser@127.0.0.1
sftpuser@127.0.0.1's password: 
Connected to sftpuser@127.0.0.1.
sftp>

In the user’s home directory, /home/sftpuser, create a new directory to confirm that everything is working. 

Here is the output.

sftp> pwd
Remote working directory: /home/sftpuser
sftp> 
sftp> mkdir sftp-check
sftp> ls 
sftp-check  
sftp>

Step 9: Connect to SFTP server via GNOME GUI

If you want to connect SFTP server via GUI, you can use either any of the FTP clients like FileZilla or the default GNOME desktop on AlmaLinux. The GNOME desktop has the ability to connect to SFTP servers from the file manager. You can connect SFTP via the GNOME desktop on AlmaLinux by following the below steps: 

1. Open the File Manager from the Activities menu.

2. Click Other Locations and enter ftp://127.0.0.1 in the Connect to Server box at the bottom of the window. Click the Connect button.

3. Enter the FTP account’s credentials that we created earlier and click the Connect button.

4. Once it is connected, you are able to open your home directory where you can upload and download files. 

Wrapping Up

AlmaLinux is CloudLinux's own open-source operating system. It is a CentOS replacement that offers a community-operated and governed operating system. AlmaLinux also gives Linux users a license-free upgrade path compatible with the pre-CentOS Stream stable versions.

If you are looking for a server to create your FTP server and account on Almalinux, Liquid Web has what you need. We offer Dedicated Server and Managed VPS Hosting options. In addition, our skilled team provides 24/7/365 support and monitoring services so that you can focus on your websites. Contact our team today to learn more.

Avatar for Mohammed Noufal

About the Author: Mohammed Noufal

Mohammed Noufal has worked as a senior server administrator for 8+ years. He can be found on LinkedIn to know more or connect.

Latest Articles

PHP 7 vs PHP 8: A Comparison

Read Article

How to Create a Symbolic Link

Read Article

What Is A Private VPS Parent?

Read Article

Managed Hosting vs Unmanaged VPS Hosting

Read Article

Why Is Your IP Address Blocked?

Read Article