The question often arises, when setting up and operating various OS distributions, how to transfer files securely over the network? Let's say at once that there are a lot of protocols, but in our opinion, one of the most effective and convenient is SFTP!
Enough, convenient to use, as it offers an interactive shell to work with the file system and a set of basic commands!
What is SFTP?
SFTP, or Secure File Transfer Protocol, is a protocol used for encrypted data transfer that supports user authentication and is often pre-installed on many distributions. Since it is technically implemented in SSH service, the configuration of users and authentication methods is absolutely identical.
Once you have exchanged public encryption keys or created a new user with a password, you should proceed to install the service if you have not already installed it.
Installing and managing files via SFTP
Usually it is enough to install openssh-server, as the other packages are downloaded by dependencies:
apt install openssh-server
For Windows it will be similar, you can find the file on the developers website, but it is better to use trusted repositories and install via the command:
Get-WindowsCapability -Online | Where-Object Name -like ‘OpenSSH.Server*’ | Add-WindowsCapability -Online
After that, to connect to the SFTP server you need to write a command with the syntax:
sftp -P port_number user_name@hostname

Let's look through the possible functionality of the utility and consider the implementation of functions on a practical example:

First of all, we need to see what directories we are in on the remote OS and locally. Unfortunately, SFTP does not support the ability to execute more than one command at a time, so they will be executed separately:
pwd
lpwd

We can then view the list of files on the remote and local device:
ls
lls

For example, we need to transfer the file t.txt to the remote device, for this we will write:
put -R local-path remote-path

The same approach can be used for commands, then it will be necessary to add the -R option to the beginning for recursive copying of data. Downloading files from a remote device can be done with the same simple command:
get -R remote-path local-path

Since sessions are interactive shells, you may need to use the local OS for a while without leaving the session:
!command-in-the-shell

If we want to open a full-fledged shell, we use the command:
!command-in-the-shell

And to exit from it q or exit. This will then open cmd for Windows and the standard specified user shell for Linux. This set of basic commands will allow secure file transfers between devices. The setup is quite simple, as the protocol and server part are already implemented in the boot package and loaded by a dependency to the machine.