Setting Up an OpenSSH Server for Rsync on Ubuntu Linux to Support Windows 11
In this article, we will cover the necessary steps to set up an OpenSSH server on Ubuntu Linux to support file transfers using the Rsync protocol for Windows 11. While the OpenSSH server is an optional feature on Windows 11, having an OpenSSH server on a Linux machine can offer a more robust and flexible file transfer solution.
Installing the OpenSSH Server on Ubuntu
To install the OpenSSH server on Ubuntu, open a terminal window and enter the following command:
sudo apt-get update && sudo apt-get install openssh-server
After the installation is complete, start the OpenSSH server by running the following command:
sudo systemctl start ssh
To ensure the OpenSSH server starts automatically when the system boots up, run the following command:
sudo systemctl enable ssh
Configuring the OpenSSH Server
The OpenSSH server configuration file is located at /etc/ssh/sshd_config. Open this file in a text editor with the following command:
sudo nano /etc/ssh/sshd_config
To enable Rsync over SSH, make sure the following line is present in the configuration file:
Subsystem sftp /usr/lib/openssh/sftp-server
Save and close the file, then restart the OpenSSH server with the following command:
sudo systemctl restart ssh
Setting Up Rsync on Ubuntu
To install Rsync on Ubuntu, run the following command:
sudo apt-get install rsync
Configuring the Firewall
By default, Ubuntu comes with a firewall enabled called UFW (Uncomplicated Firewall). To allow SSH traffic through the firewall, run the following command:
sudo ufw allow 22
To allow Rsync traffic through the firewall, run the following command:
sudo ufw allow 873/tcp
Transferring Files Using Rsync
To transfer files from a Windows 11 machine to the Ubuntu machine, use the following command:
rsync -avz --progress /path/to/source user@ubuntu_ip:/path/to/destination
Replace /path/to/source with the path to the source directory on the Windows 11 machine. Replace user@ubuntu_ip with the username and IP address of the Ubuntu machine. Replace /path/to/destination with the path to the destination directory on the Ubuntu machine. The -avz options enable archiving, compression, and transfer progress. This command will also create the destination directory if it does not exist.
- Install the OpenSSH server on Ubuntu using
sudo apt-get install openssh-server. - Start the OpenSSH server using
sudo systemctl start sshand enable it to start automatically on boot usingsudo systemctl enable ssh. - Configure the OpenSSH server by editing the
/etc/ssh/sshd_configfile and ensuringSubsystem sftp /usr/lib/openssh/sftp-serveris present. - Install Rsync on Ubuntu using
sudo apt-get install rsync. - Configure the firewall using
sudo ufw allow 22to allow SSH traffic andsudo ufw allow 873/tcpto allow Rsync traffic. - Transfer files using the
rsync -avz --progress /path/to/source user@ubuntu_ip:/path/to/destinationcommand.