How to Install OpenSSH SFTP Server on Ubuntu Server Latest
OpenSSH SFTP server is a powerful tool that allows you to secure file transfers over an encrypted SSH connection. In this tutorial, we will guide you through the process of installing OpenSSH SFTP server on Ubuntu Server Latest.
Prerequisites
Before proceeding with the installation process, you must have the following prerequisites:
- Ubuntu Server Latest installed.
- Sudo privileges.
Step 1: Update and Upgrade System
The first step is to update and upgrade the system to ensure that all the packages are up to date.
$ sudo apt-get update && sudo apt-get upgrade
Step 2: Install OpenSSH Server
Next, we need to install the OpenSSH server on Ubuntu. Run the following command:
$ sudo apt-get install openssh-server
Step 3: Configure the OpenSSH Server
Once the installation is complete, we need to configure the OpenSSH server to enable SFTP service. Here's how:
- Open the configuration file
/etc/ssh/sshd_configusing any text editor.
$ sudo nano /etc/ssh/sshd_config
- Uncomment the following line:
#Subsystem sftp /usr/lib/openssh/sftp-server
Change it to:
Subsystem sftp internal-sftp
- Add the following configuration at the end of the file:
Match group sftp
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
- Save and close the file.
Step 4: Create SFTP User
In this step, we will create an SFTP-only user that will be used to upload/download files. Run the following commands:
$ sudo groupadd sftp
$ sudo useradd -g sftp -d /incoming -s /usr/sbin/nologin sftp_user
$ sudo passwd sftp_user
$ sudo mkdir /home/sftp_user/incoming
$ sudo chown sftp_user:sftp /home/sftp_user/incoming
These commands will create a new sftp group, an SFTP-only user called sftp_user, and a directory called incoming within the home directory of sftp_user.
Step 5: Restart the SSH Service
After making the necessary changes, restart the SSH service to apply the new settings.
$ sudo systemctl restart ssh
Step 6: Test the SFTP Server
Now that the SFTP server is configured, it's time to test if it's working. Here's how:
- Open any SFTP client (FileZilla, WinSCP, Cyberduck, etc.)
- Connect to the Ubuntu server using the SFTP-only user account (
sftp_userin our case). - Try uploading/downloading files to/from the
incomingdirectory.
If everything is working perfectly, the files should upload/download successfully.
Conclusion
Congratulations! You have successfully installed and configured the OpenSSH SFTP server on Ubuntu Server Latest. It is a powerful tool that can help you securely transfer files over an encrypted SSH connection.