List of content you will read in this article:
There are many ways you can transfer files over the internet and SFTP is one of them. Today we will show you how to connect to SFTP on CentOS without Shell access. Before getting to the tutorial, however, let us first get down to the basics and explain what exactly SFTP is.
What is SFTP?
The SFTP, or the Secure File Transfer Protocol, is a file transfer protocol that is activated by default after installing Secure Shell on the Linux operating system. Using SFTP, you will be able to transfer or receive your files through a secure Linux tunnel.
This protocol is often confused with the FTP protocol or its unsecured form, but it should be noted that this protocol generally has all of its own rules and conditions, and has nothing similar to the rules with FTP. Default access is provided to SFTP when the user has access to the shell, the SSH console, and the Linux Command Line Console.
Now, in this tutorial, we're going to teach SFTP access without the need for Shell in CentOS, with the setup that runs on the Linux VPS server so you can easily give users access to the file transfer without being able to connect to Shell.
SFTP Access without Shell in CentOS
For the sake of convenience, we used the name Elizabet as an example.
Step 1: Connect to your Centos VPS system first through SSH and Root user.
Step 2: Then enter the following commands to define a new username and password for it.
Step 3: After entering the second command, enter the password twice to set the password on the user.
Step 4: Now create a directory to access the SFTP for the user you want.
mkdir -p / var / sftp / files
In this command, a directory named SFTP is created and inside it is created another directory named files.
Step 5: Give the root user permission to access these directories.
chown root: root / var / sftp
Step 6: Then provide the necessary access to file the user to the file directory.
chown elizabet: elizabet / var / sftp / files
Step 7: Then, open the SSH configuration file with the Nano editor or any other editor you want.
nano / etc / ssh / sshd_config
Step 8: Copy the following statements at the end of the file. Then save the file and exit.
Match User Elizabet
ChrootDirectory / var / sftp
Permit tunnel no
Please note that in the Match User section, you must enter the username you created, and in the ChrootDirectory section, also enter the directory address created for this user.
Step 9: Restart the service to make changes to the SSH service.
systemctl restart sshd
You can now connect to your Linux through WinSCP software or other SFTP commands from another Linux user.
We hope that this article has helped you expand your knowledge about the SFTP protocol. With the help of the above tutorial, you can connect to SFTP on CentOS without shell access. If you would like to do it on Ubuntu instead, check out this article. If you have any questions or suggestions, please leave a comment in the comment section below.