Blog Post Header
Tutorials December 25, 2025 11 views

How to Set Up SFTP in CentOS

How to Set Up SFTP in CentOS

How to Set Up SFTP in CentOS

SFTP (Secure File Transfer Protocol) is a secure way to transfer files between a client and a server. In this tutorial, we will guide you through the process of setting up SFTP on a CentOS server.

Step 1: Install OpenSSH

The first step is to install OpenSSH on your CentOS server. OpenSSH is a suite of tools that provides secure communication between two systems using the SSH protocol.

sudo yum install openssh-server

Step 2: Configure SSH

Next, you need to configure the SSH server to allow SFTP access. Open the SSH configuration file in a text editor:

sudo vi /etc/ssh/sshd_config

Find the following line and uncomment it (remove the "#" at the beginning of the line):

Subsystem sftp /usr/libexec/openssh/sftp-server

Save the file and restart the SSH service to apply the changes:

sudo systemctl restart sshd

Step 3: Create SFTP User

Now, you need to create a new user who will have SFTP access. You can create a new user using the following command:

sudo adduser sftp_user

Set a password for the new user when prompted. Once the user is created, you can restrict their access to SFTP only by changing their shell to the SFTP server:

sudo usermod -s /bin/false sftp_user

Step 4: Set Permissions

It is important to set the correct permissions for the directory that the SFTP user will have access to. Change the ownership of the directory to the SFTP user:

sudo chown sftp_user:sftp_user /path/to/directory

Make sure the directory has the correct permissions:

sudo chmod 700 /path/to/directory

Step 5: Test SFTP Connection

Finally, you can test the SFTP connection using an SFTP client such as FileZilla or WinSCP. Enter the server IP address, username, and password to establish a secure connection.

Conclusion

Setting up SFTP on a CentOS server is a simple process that involves installing OpenSSH, configuring the SSH server, creating an SFTP user, setting permissions, and testing the connection. By following the steps outlined in this tutorial, you can securely transfer files to and from your CentOS server using SFTP.

Author: Admin
Join Our Community

Create an account to leave comments, save your favorite posts, and get personalized recommendations.