Posted On July 31, 2026

How to Set Up an FTP Server and an SFTP Server on Ubuntu

Think 0 comments
>> Dedicated , Scripts >> How to Set Up an FTP Server and an SFTP Server on Ubuntu

If you need to transfer files to and from your Ubuntu server, there are two popular options:

  • FTP (File Transfer Protocol) – Compatible with many legacy applications but requires additional configuration to be secure.
  • SFTP (SSH File Transfer Protocol) – Built into SSH, encrypted by default, and the recommended choice for most users.

In this guide, you’ll learn how to set up both an FTP server using vsftpd and an SFTP-only server on Ubuntu.


Part 1: Setting Up an FTP Server (vsftpd)

Step 1: Update Your Server

Before installing new software, update your system:

sudo apt update
sudo apt upgrade -y

Step 2: Install vsftpd

Install the Very Secure FTP Daemon (vsftpd):

sudo apt install vsftpd -y

Step 3: Enable and Start the Service

sudo systemctl enable vsftpd
sudo systemctl start vsftpd
sudo systemctl status vsftpd

If everything is working, you’ll see:

Active: active (running)

Step 4: Back Up the Configuration File

Always create a backup before making changes:

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

Step 5: Configure vsftpd

Open the configuration file:

sudo nano /etc/vsftpd.conf

Make sure these settings are present:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022

dirmessage_enable=YES
use_localtime=YES

xferlog_enable=YES

connect_from_port_20=YES

chroot_local_user=YES
allow_writeable_chroot=YES

listen=YES
listen_ipv6=NO

Save the file and exit the editor.


Step 6: Enable Passive Mode

Add the following to the end of the configuration file:

pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100

Passive mode improves compatibility with most FTP clients.


Step 7: Restart vsftpd

sudo systemctl restart vsftpd

Step 8: Create an FTP User

sudo adduser ftpuser

Follow the prompts to create a password.


Step 9: Configure the Firewall

If you’re using UFW:

sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw allow 40000:40100/tcp
sudo ufw reload

Verify the rules:

sudo ufw status

Step 10: Connect to Your FTP Server

Using FileZilla or another FTP client:

Host

ftp://YOUR_SERVER_IP

Port

21

Username

ftpuser

Password

Your FTP password

Part 2: Setting Up an SFTP Server

Unlike FTP, SFTP is built into OpenSSH and uses encryption by default.

Step 1: Install OpenSSH Server

Most Ubuntu servers already have it installed.

To verify:

sudo systemctl status ssh

If SSH isn’t installed:

sudo apt update
sudo apt install openssh-server -y

Enable the service:

sudo systemctl enable ssh
sudo systemctl start ssh

Step 2: Create an SFTP User

sudo adduser sftpuser

Step 3: Create an SFTP Group

sudo groupadd sftpusers
sudo usermod -aG sftpusers sftpuser

Step 4: Configure SSH for SFTP Only

Open the SSH configuration:

sudo nano /etc/ssh/sshd_config

Add this to the end of the file:

Match Group sftpusers
    ChrootDirectory /home/%u
    ForceCommand internal-sftp
    PasswordAuthentication yes
    AllowTcpForwarding no
    X11Forwarding no

This configuration:

  • Restricts users to SFTP only
  • Prevents SSH shell access
  • Jails users inside their home directory

Step 5: Set Folder Permissions

The chroot directory must be owned by root:

sudo chown root:root /home/sftpuser
sudo chmod 755 /home/sftpuser

Create a writable upload folder:

sudo mkdir /home/sftpuser/uploads
sudo chown sftpuser:sftpuser /home/sftpuser/uploads

Users will upload files into the uploads directory.


Step 6: Restart SSH

sudo systemctl restart ssh

Step 7: Connect with an SFTP Client

Open FileZilla, WinSCP, Cyberduck, or another SFTP client.

Use these settings:

Protocol

SFTP - SSH File Transfer Protocol

Host

YOUR_SERVER_IP

Port

22

Username

sftpuser

Password

Your SFTP password

The user will be able to transfer files but won’t have terminal access.


FTP vs. SFTP

FeatureFTPSFTP
EncryptionNo (unless using FTPS)Yes
Port2122
Requires SSHNoYes
Built into UbuntuNoYes
RecommendedLegacy compatibilityYes
Secure by DefaultNoYes

Troubleshooting

Permission Denied

Check ownership:

ls -ld /home/username

Change ownership if necessary:

sudo chown -R username:username /home/username

Check Permissions

ls -la /home/username

Restart Services

FTP:

sudo systemctl restart vsftpd

SFTP (SSH):

sudo systemctl restart ssh

Check Service Status

FTP:

sudo systemctl status vsftpd

SSH:

sudo systemctl status ssh

Which Should You Choose?

If you’re starting fresh, SFTP is the best option. It’s built into Ubuntu, encrypted by default, requires no separate FTP server, and is supported by nearly every modern file transfer client.

Choose FTP only if you need compatibility with older software or systems that specifically require the FTP protocol.

By following this guide, you’ll have a secure file transfer solution running on your Ubuntu server, whether you choose FTP for legacy support or SFTP for modern, encrypted file transfers.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Best Sites To Rent Virtual Servers From

Most of these sites I have used my self to buy virtual private servers from…

Must-Have Apps on Cloudron: From Productivity to Privacy

Cloudron offers a wide variety of self-hosted applications that are perfect for a "top picks"…

World Monitor Script

Real-time global intelligence dashboard — AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified…