
Secure file transfer protocol (SFTP) is a secure way of transferring files between a local and remote computer using an encrypted SSH session. It is an improved version of the traditional file transfer protocol (FTP), which adds a layer of security during the file transfer and connection establishment processes.
In this guide, you will set up SFTP User accounts on Ubuntu 20.04, and allow the user to strictly access files within the home directory.
Create a new SFTP Users Group. Replace sftpcorner with your desired group name.
Create a new user account. Replace exampleuser with your desired user name.
Enter the user’s full name, password to continue.
Then, add the user to the SFTP group.
Restrict the user from accessing files outside the home directory.
Now, create new subdirectories within the user home directory. These are used for file transfer.
Grant the user ownership rights to the subdirectories.
Then, allow read and write permissions to all files within the home directory.
With the sftp group and user accounts created, enable SFTP in the main SSH configuration file.
Using an editor of your choice, open the file /etc/ssh/sshd_config.
Add the following lines to the end of the file. Replace sftpcorner with your actual sftp group.
Save and close the file.
Below are the functions for each of the above configuration lines:
sftpcorner.Also, confirm if SFTP is enabled (it is by default). The line below should be uncommented in /etc/ssh/sshd_config:
Restart the SSH server for changes to take effect.
Open a new terminal window and log in with sftp using a valid user account and password.
OR
List files within the directory. Your output should be similar to the one below:
Also, try creating a new directory within the subdirectory to test user permissions.
Confirm creation of the new directory:
FileZilla and Cyberduck are the most popular SFTP clients available for Windows, Mac, and Linux desktop to test connectivity using a desktop client.
In this guide, you successfully set up SFTP on a Ubuntu 20.04 server, then tested connectivity through a terminal session and FileZilla. You can create multiple users with different directories to securely upload and download files on your server.
0 Comments
Be the first to comment and share your perspective with the community.