Connect to SFTP on CentOS Without Shell Access

Connect to SFTP on CentOS Without Shell Access, In this tutorial, we will first touch up on what is SFTP and then give you a step-by-step tutorial on how to access it via CentOS without having shell access.

Updated: 05 Mar, 23 by Elizabet J 3 Min

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.

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.

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.
adduser elizabet
passwd  elizabet
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
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory / var / sftp
Permit tunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding 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.

Elizabet J

Elizabet J

One OF my major goals is getting new experiences about ICT and what’s more making progress through this field.

user monovm

Sidney Larkin

2024, Nov, 24

Great post! This guide on connecting to SFTP on CentOS without shell access is extremely helpful for those looking to manage secure file transfers on their system. The step-by-step instructions, especially the examples with user creation and directory permissions, make it easy to follow along. It's also nice that you've covered alternatives for different Linux systems, linking to the Ubuntu tutorial. This is a fantastic resource for anyone new to SFTP management. Keep up the great work!