TechTorch

Location:HOME > Technology > content

Technology

Guide to Installing and Configuring an FTP Server with vsftpd on Ubuntu

February 16, 2025Technology3338
Guide to Installing and Configuring an FTP Server with vsftpd on Ubunt

Guide to Installing and Configuring an FTP Server with vsftpd on Ubuntu

With the increasing need for reliable file transfer services, setting up an FTP server can be a valuable step for both personal and professional use. This guide will walk you through the process of installing and configuring an FTP server using vsftpd (Very Secure FTP Daemon) on an Ubuntu system. Follow these detailed steps to ensure a secure and efficient FTP server setup.

Installation and Basic Configuration

First, ensure that the necessary packages are installed on your Ubuntu system. The most common method is to use the package manager apt-get. Execute the following command to install vsftpd:

sudo apt-get install vsftpd -y

After the installation is complete, start the vsftpd service and set it to start automatically upon system boot:

sudo systemctl start vsftpd sudo systemctl enable vsftpd

Create a User and Directory Structure

To begin using the FTP server, we need to create a user and configure the directory structure to which this user will have access.

Create a new user account:

sudo adduser testuser1

Create a directory for the FTP server and set the ownership to the relevant user and group:

sudo mkdir /home/testuser1/ftp sudo chown nobody:nogroup /home/testuser1/ftp sudo chmod a-w /home/testuser1/ftp

Create a directory for file uploads and set the correct ownership:

sudo mkdir /home/testuser1/ftp/test sudo chown testuser1:testuser1 /home/testuser1/ftp/test

Backup and Edit vsftpd’s Configuration

Before making any changes to vsftpd’s configuration, it is a good practice to backup the original configuration file:

sudo cp

Next, open the configuration file:

sudo nano

Add or modify the following settings in the configuration file:

listenNO - This setting disables the standalone mode and forces vsftpd to run in daemon mode.

listen_ipv6YES - Enable IPv6 support.

anonymous_enableNO - Disable anonymous FTP access.

local_enableYES - Enable local user FTP access.

write_enableYES - Enable file writing for local users.

local_umask022 - Set the umask value for local users.

dirmessage_enableYES - Enable directory messages.

use_localtimeYES - Use the local time on the server.

xferlog_enableYES - Enable transfer logging.

connect_from_port_20YES - Allow data connections on port 20.

chroot_local_userYES - Restrict local users to their home directories.

secure_chroot_dir/var/run/vsftpd/empty - Set the secure chroot directory.

pam_service_namevsftpd - Specifies the PAM service name.

pasv_enableYES - Enable passive mode.

pasv_min_port10000 - Set the minimum port number for passive mode.

pasv_max_port11000 - Set the maximum port number for passive mode.

user_sub_tokenUSER - Replace all instances of USER with the actual username.

local_root/home/USER/ftp - Set the root directory for local users.

userlist_enableYES - Enable userlist.

userlist_file_list - Set the userlist file.

userlist_denyNO - Set to NO to allow access for users listed in the userlist file.

Save and close the configuration file.

Note: vsftpd has a multitude of configuration options to tailor the FTP server to your specific needs. Ensure you make any necessary adjustments based on your local server setup.

Adding the User to the User List

To control who can access the FTP server, add the previously created user to the user list:

sudo nano _list

Enter the username testuser1 and save the file.

Restarting the vsftpd Service

Finally, restart the vsftpd service to apply the new configuration changes:

sudo systemctl restart vsftpd

With these steps, you have successfully installed and configured an FTP server using vsftpd on Ubuntu. Now, you can securely manage file transfers for your users.