SFTP
What is SFTP?
SFTP is the SSH File Transfer Protocol, an extension of Secure Shell (SSH) that provides secure file transfer capabilities. It should not be confused with FTP or FTPS. Unlike FTP, SFTP encrypts both commands and data, preventing passwords and sensitive information from being transmitted in plain text. It cannot interoperate with FTP software. FTPS extends the FTP standard so clients can request encrypted FTP sessions by sending the AUTH TLS command.
Setting Up a Simple Server
The goal is to set up an SFTP server where users are restricted to their home directory and have limited system privileges.
Setting Up the Server
Assuming SSH is already installed, edit the SSH server configuration file:
-
Open the config file:
-
Comment out the following line by adding a
#at the beginning: -
Add the following at the end of the file:
-
Restart SSH:
Creating the sftpusers Group
Creating SFTP Users
-
Create the user:
-
Prevent SSH login and assign the user to the SFTP group:
-
Restrict the user to their home directory:
-
Create a folder to which the user can upload files: