I will describe in this post what is sftp client for Linux and how to use it to secure file transfer. There are also list basic commands and some examples. Тоже по-русски
SFTP (Secure FTP) – a network application layer protocol used to copy files to/from a remote system over a reliable and secure connection. Unlike the FTP, data and commands are transmitted over the Internet in encrypted form.
sftp client – a program that uses the SFTP protocol to access, manage, and transfer files. To connect sftp client to the server, there must be installed and set up ssh server. How to set up ssh server is described in my post “Setup ssh server“.
To start sftp session, in Linux or MAC OS terminal, one have to type:
where username is user name, host – fully qualified domain name or IP address of the server.
For example, the username is admin and IP address of the server 192.168.22.4. Then command to start sftp session is (Fig. 1.)
Each session terminates with command exit.
Once a session is started, the user can use commands to transmit or manage files:
1. The sftp client file transfer commands:
- put filename transfers file filename to the server;
- get filename downloads file filename from the server to the client’s computer.
File names can contain the asterisk as a symbol that replaces several other characters to facilitate typing when it is necessary to transfer multiple files with a single command, for example:
put a * sends all files that start with the letter «a»to the server.
2. sftp client remote computer commands:
- cd foldername goes to the folder foldername;
- ls lists current remote folder contents;
- mkdir foldername creates folder foldername on the server;
- pwd shows path to the current folder on the server;
- rm filename removes file filename on the server;
- rmdir foldername removes folder foldername on the server.
3. Local computer commands:
- lcd foldername goes to folder foldername;
- ls lists current local folder contents;
- lmkdir foldername creates folder foldername on the local computer;
- lpwd shows path to the current folder on the local computer.
Using listed above sftp client commands, one can not just transfer files, but perform basic operations on them as well.
Good advice. To use sftp client to anything other than file transfer, in my opinion, is not the best idea. Usually, in parallel with the sftp session I open one or may be several ssh sessions and perform all necessary operations with files and folders using ssh terminal, which is much more convenient.
I have shortly described what is sftp client for Linux and how to use it to secure file transfer. There are also list basic commands and some examples.