How To Setup SFTP Server on Ubuntu 22.04 LTS

In this post, we’ll walk you through the steps to setup an SFTP server on Ubuntu 22.04.

SFTP (Secure File Transfer Protocol) is a secure way to transfer files between systems using an encrypted connection. It’s a great way to ensure your files are secure while transferring them from one location to another. If you’re using Ubuntu 22.04, you can easily set up an SFTP server to transfer files securely.


  • Pre-Installed Ubuntu 22.04
  • Sudo User with Admin rights
  • Internet Connectivity

Without any delay, let’s jump into the actual steps.

1) Install SSH Server

To set up an SFTP server, you need to have an SSH server installed. To install SSH server, open your terminal and type the following command:

$ sudo apt update
$ sudo apt install ssh -y

2) Create SFTP Group and User

It’s always a good practice to create a new user for SFTP transfers. Before creating a user, let’s first create group with a name “sftp

$ sudo groupadd sftp

Now, create a user and add it to sftp group,

$ sudo useradd -m sftpuser -g sftp

Assign password to sftpuser,

$ sudo passwd sftpuser

Output of above commands,


In the last, grant full permissions to user’s home directory, run

$ sudo chmod 700 /home/sftpuser/

3) Configure SSH Server

Once you have created group and new user, you need to configure the SSH server to allow SFTP access. Open the sshd_config file using vi editor,

$ sudo vi /etc/ssh/sshd_config

Change ‘Subsystem sftp /usr/lib/openssh/sftp-server‘  to ‘Subsystem sftp  internal-sftp

Add the following lines at the end of the file:

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

Save and exit the file,


  • The Match Group directive will create a group “sftp”. This group will be used to restrict SFTP users to their home directories.
  • The ChrootDirectory directive will change the root directory of the SFTP user to their home directory.
  • The ForceCommand directive will force the use of the internal-sftp subsystem and disable all other SSH functionality.
  • The AllowTcpForwarding directive will disable TCP forwarding, which can be used to bypass restrictions.

4) Restart SSH Server

After configuring the SSH server, you need to restart it using the following command:

$ sudo systemctl restart sshd

5) Test SFTP Server

Now, you can test the SFTP connection using any SFTP client. Connect to your SFTP server using the IP address or hostname of your server, username and password of the newly created user,

$ sftp sftpuser@


Great! output above confirm that you have successfully set up an SFTP server on Ubuntu 22.04. You can now use this server to transfer files securely between systems.

Also Read: How to Install Brave Web Browser on Ubuntu 22.04

Leave a Comment

twenty + 9 =