How to Setup SFTP Server on Ubuntu 20.04 (2024)

In today's interconnected digital world, the need for secure file transfers is paramount. Whether you're managing sensitive business documents or sharing personal files, security and reliability are non-negotiable. This is where SFTP (Secure File Transfer Protocol) comes into play. If you're a user of Ubuntu 20.04, you're in luck, as it provides an excellent platform for setting up your own SFTP server, ensuring your data remains confidential and protected during transfers.

In this comprehensive guide, we'll take you through the process of creating an SFTP server on your Ubuntu 20.04 system. Whether you want a secure way to share files with colleagues or establish a remote backup system, this step-by-step tutorial will empower you to achieve your goals.

What is SFTP?

Secure File Transfer Protocol (SFTP) is a secure and encrypted file transfer protocol designed to provide a safe way to exchange data between a client and a server. It builds upon the SSH (Secure Shell) protocol, making it an excellent choice for securely moving files over the internet or within a local network.

Features of SFTP

* Encryption: SFTP encrypts both the data being transferred and the authentication process, ensuring that your files are safe from eavesdropping and tampering.

* Authentication: It uses SSH keys or passwords for user authentication, making it easy to control access to your server.

* Portability: SFTP is widely supported on various operating systems, making it a versatile choice for cross-platform file transfers.

* Integrity: Files transferred via SFTP are checked for integrity to ensure that they haven't been altered during the transfer process.

* Remote Access: SFTP allows you to access and manage your files remotely, which is particularly useful for administrators and remote workers.

Now that you understand the significance of SFTP, let's proceed with the installation and setup on your Ubuntu 20.04 system.

Installation Steps

Step 1: Install OpenSSH Server

Ubuntu comes with OpenSSH pre-installed, but it's a good practice to ensure it's up to date. You can do this by installing or updating the OpenSSH server using the following command:

$ sudo apt install ssh

Step 2: Modifying the SSHD Configuration for the SFTP Group

After successfully installing the SSH server, the next crucial step is to make the necessary modifications to the SSHD configuration file located at /etc/ssh/sshd_config. To do this, you can use the nano text editor or any other text editor of your choice. Here's how to open and edit the configuration file:

$ sudo nano /etc/ssh/sshd_config

Now, paste the following lines at the end or bottom of the file:

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

How to Setup SFTP Server on Ubuntu 20.04 (1)

Save the file and exit the text editor.

Step 3: Restart SSH services

For making the new changes to take effect, restart the SSH service using the ‘systemctl’ command:

$ sudo systemctl restart ssh

Step 4: Create an SFTP Group

To facilitate SFTP access for users, the initial step involves the creation of a dedicated user group for SFTP users. To streamline the process, all SFTP users will be part of this common group. Execute the following command to create this group:

$ sudo addgroup sftp

Step 5: Create a new SFTP user

Now that you've added the new "sftp" group, it's time to create a new SFTP user and ensure they are a part of the "sftp" group. To achieve this, run the following command:

$ sudo useradd -m sftp_user -g sftp

Set the password for the newly created sftp user by typing the following command:

$ sudo passwd sftp_user

Step 6: Restrict Access to the User's Home Directory

In this step, we will ensure that the SFTP user has exclusive access to their home directory while denying access to other users on the system. To achieve this, set the appropriate permissions using the 'chmod' command as shown below:

$ sudo chmod 700 /home/sftp_user/

This command restricts access to the specified user's home directory, making it accessible only to the owner (the SFTP user) while denying access to others.

The SFTP server configurations have now been successfully finalized. To ensure that everything is functioning as expected, you can proceed to log in using the SFTP credentials.

Login through the SFTP using command line

You can establish an SFTP connection using either the IP address or system hostname. In this example, we'll connect to the SFTP server running on the same system where we configured it.

Step 1: Open a terminal and connect to the SFTP server using the sftp_user's name along with the loopback address 127.0.0.1. Use the following commands:

$ sftp sftp_user@127.0.0.1

Upon your initial connection attempt via SFTP, you will encounter a dialogue prompt on the terminal screen. To proceed with the connection, simply respond by entering 'yes.' Following this confirmation, proceed to set the password for the SFTP user. Once this is accomplished, you will observe the message "connected to 127.0.0.1" displayed in the terminal window, indicating a successful SFTP login.

How to Setup SFTP Server on Ubuntu 20.04 (2)

To navigate to the SFTP user's home directory and create a new directory named 'test-sftp', you can use the following commands:

sftp> cd sftp_user
sftp> mkdir test-sftp
sftp> ls

Congratulations! You've successfully set up an SFTP server on your Ubuntu 20.04 system. This secure file transfer solution is not only practical but also ensures the safety and integrity of your data during transfers. Whether you're sharing files with colleagues or creating remote backups, your SFTP server is ready to serve your needs.

How to Setup SFTP Server on Ubuntu 20.04 (2024)
Top Articles
The Eye of Horus By Jane Olver
What is Rebate Marketing?
Bubble Guppies Who's Gonna Play The Big Bad Wolf Dailymotion
Jordanbush Only Fans
Star Sessions Imx
Canary im Test: Ein All-in-One Überwachungssystem? - HouseControllers
Celebrity Extra
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
Here are all the MTV VMA winners, even the awards they announced during the ads
Exam With A Social Studies Section Crossword
Sprague Brook Park Camping Reservations
ds. J.C. van Trigt - Lukas 23:42-43 - Preekaantekeningen
Caroline Cps.powerschool.com
2021 Lexus IS for sale - Richardson, TX - craigslist
Bc Hyundai Tupelo Ms
My.doculivery.com/Crowncork
Craigslist Cars Nwi
Labor Gigs On Craigslist
Kris Carolla Obituary
Love In The Air Ep 9 Eng Sub Dailymotion
Les Rainwater Auto Sales
ARK: Survival Evolved Valguero Map Guide: Resource Locations, Bosses, & Dinos
Craighead County Sheriff's Department
Metro Pcs.near Me
Craigslist Appomattox Va
Ahrefs Koopje
Qual o significado log out?
Winco Employee Handbook 2022
Wisconsin Volleyball Team Boobs Uncensored
Trivago Myrtle Beach Hotels
A Christmas Horse - Alison Senxation
Angel Haynes Dropbox
Robert A McDougal: XPP Tutorial
Kacey King Ranch
Primerica Shareholder Account
Busted! 29 New Arrests in Portsmouth, Ohio – 03/27/22 Scioto County Mugshots
Craigslist Cars And Trucks Mcallen
R3Vlimited Forum
Mcgiftcardmall.con
2700 Yen To Usd
Сталь aisi 310s российский аналог
Three V Plymouth
Craigslist Malone New York
Cocorahs South Dakota
Paul Shelesh
30 Years Of Adonis Eng Sub
Bustednewspaper.com Rockbridge County Va
Leland Westerlund
Acuity Eye Group - La Quinta Photos
St Als Elm Clinic
A Snowy Day In Oakland Showtimes Near Maya Pittsburg Cinemas
Latest Posts
Article information

Author: Reed Wilderman

Last Updated:

Views: 5563

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.