sftp Command Examples in Linux

SFTP is a file transfer system that runs on top of an SSH connection and emulates an FTP interface. It requires an SSH server on the remote system instead of an FTP server. It provides an interactive session with an sftp prompt.

Sftp supports the same commands as ftp and lftp.

To start an sftp session, use the following command:

$ sftp user@domainname 

Similar to lftp, the sftp session can be terminated by typing the quit command.

Sometimes, the SSH server will not be running at the default port 22. If it is running at a different port, we can specify the port along with sftp as -oPort=PORTNO. Consider this example:

$ sftp -oPort=422 user@slynux.org 

-oPort should be the first argument of the sftp command.

sftp Command Examples

1. To ftp a particular host:

# sftp 192.168.27.100

2. To specify the use of protocol version 1:

# sftp -1 192.168.27.100 

3. To specify the size of buffer when sftp uses to transfer files:

# sftp -B 1024 192.168.27.100 

4. To enable compression:

# sftp -C 192.168.27.100

5. To specify the shh confiduration file to be used:

# sftp -F ssh_config 192.168.27.100 

6. To pass ssh options:

# sftp -o ssh_options 192.168.27.100 

7. To connect directly to a local sftp server:

# sftp -P 

8. To specify how many requests may be outstanding at any one time:

# sftp -R 10 192.168.27.100 

9. To specify the name of the program to be used for encryption:

# sftp -S program 192.168.27.100 

10. To specifies the SSH2 subsystem or the path for an sftp server on the remote host:

# sftp -s subsystem 192.168.27.100 

11. To raise the logging level:

# sftp -v 192.168.27.100 

SFTP uses port 22 to exchange data securely on a network, unlike FTP, which sends data in plain-text, a malicious user can see what’s being sent across between the FTP client and the FTP server. To improve security, SFTP was developed to provide encryption between the client and server while providing the functionality of FTP. This ensures any data/files exchanged are keep confidential from others. This post provided some of the most commonly used sftp command examples. Hope you will be using them in real world.

Related Post