How to Configure SFTP on a VPS Server?

If you have a Virtual Private Server (VPS) and want to set up Secure File Transfer Protocol (SFTP) to manage your files, this guide will help you do it quickly and easily.

Let’s start with the fact that SFTP is a secure file transfer protocol that uses encryption to protect your information. It’s a great alternative to plain FTP, which transmits data in the open and is less secure.

To configure SFTP on your VPS server, you will need command-line access and administrator credentials.

Step 1: Installing OpenSSH

The first step is to install OpenSSH, which is the software for secure data transfer via the SSH protocol.

VPS Hosting

Virtual servers with guaranteed resources

Choose VPS

Run the following command in your terminal:

sudo apt install openssh-server

After installing the OpenSSH server, you will be able to use SFTP to transfer files to your VPS server.

Step 2: Creating a New User

Create a new user who will use SFTP to access your VPS server. This will allow you to manage access and the security of your information.

Use the following command to create a new user:

sudo adduser username

Replace «username» with your desired username.

Step 3: Configuring SFTP Access

Now configure SFTP access for the created user. Edit the SSH configuration file by entering the following command:

sudo nano /etc/ssh/sshd_config

Find the line «Subsystem sftp /usr/lib/openssh/sftp-server» and change it to:

Subsystem sftp internal-sftp

Add the following block to the end of the file:

Match User username ChrootDirectory /home/username ForceCommand internal-sftp

After making changes to the configuration file, restart the SSH service:

sudo systemctl restart sshd

Step 4: Connecting to the Server via SFTP

Now you can connect to your VPS server via SFTP using an SFTP client such as FileZilla or WinSCP. Enter the server’s IP address, username, and password to start transferring files securely.

Now you have SFTP configured on your VPS server. Using this secure file transfer protocol, you can manage your data safely and efficiently.