SFTP & SSH
SFTP, or the SSH File Transfer Protocol, is a tool for transferring files between systems and is an extension of the SSH protocol. SFTP gives you access to the terminal of both the machine you are using, as well as the system you are connecting to, at the same time.
SSH, or the Secure Shell Protocol, is a method of connecting to the terminal of another system. Without it, we cannot use SFTP. It needs to be set up and configured on both ends, however it’s not too difficult a process. The best guide I’ve found is homebrewserver.club’s Demystifying SSH tutorial. Following it with zero experience, I was able to get SSH set up with no issues fairly quickly and highly recommend it if you’re also a beginner wanting to get into SSH.
Connecting with SFTP to a system is identical to SSH, using the address or set server name alongside the command. Another similarity is stopping the connection, Ctrl + D doing so on Linux.
As you’re essentially controlling two terminals with one command line, a trick is needed to tell SFTP which end we want to execute a command at. This is done by putting a lowercase L before our command to denote local execution, so for expample cd would become lcd when we want to go somewhere in the filesystem in the device were using SFTP on.
Using a command on the connected end.
Using a command on the local end.
We can send files both ways across the connection. There are specific commands used for sending files to and from the connected system.
Putting Files on the connected system.
sftp> put location/filename
Getting Files from the connected system.
sftp> get location/filename
To transfer a whole directory of files, the -r flag can be used.