Home » linux-commands » Examples of SFTP command to transfer files on linux system

Examples of SFTP command to transfer files on linux system

SSH File Transfer Protocol also known as Secure File Transfer Protocol, or SFTP, it is a internet network protocol for managing the files and directories from remote location. SFTP allows users to file transfer, file access and file management utilities over the linux servers. It was developed by the Internet Engineering Task Force (IETF).
Why is secure
As File Transfer Protocol use unencrypted algorithm (FTP use the clear text data transmission) to transfer data between host over the public internet but SFTP Internet protocol use the encrypted algorithm which prevents password, sensitive and confidential information transmission in clear data format over the public network.
How to connect
Today SFTP is widely used and preferred by users due to security reasons as SFTP establish the secure connection between host over the public and local network for data transmission.
SFTP generally the SSH authentication to make the secure connection that’s why the same authentication algorithm is applicable to make connection which is setup and configured for SSH. But we suggest to use the SSH key base authentication to make the ssh connection over public network so you need to transfer your public key to the system to access the SFTP without password authentication.
How to change the vsftpd server default port 21 to alternate port.
If you want connect to the system using SSH, execute the following command:

view the current working direcotry.
The lpwd command generally use to see the local system present working and direcotry and “pwd”
command used to see remote working directory.

sftp> lpwd

/home/localuser present working directory on local system

sftp> pwd

/linuxpcfix present working directory on remote system
Upload and Downloads using SFTP.
To upload the files on the server use the put command as given below. You must specify at least one path after a put command.

sftp> put views-7.x-3.10.zip
Uploading views-7.x-3.10.zip to /home/linuxpcfix/views-7.x-3.10.zip
views-7.x-3.10.zip 100% 1853KB 57.9KB/s 00:32

To download the files from remote system to local system using get command, as given below.

sftp> get csf.tar.gz
Fetching /home/linuxpcfix csf.tar.gz to csf.tar.gz
/home/linuxpcfix/csf.tar.gz 100% 211KB 52.6KB/s 00:04

To listing the files and directories
Use the ls command to listing files and directories on remote system

sftp> ls

use the lls command to listing files and directories on local system

sftp> lls

Create and Remove directories.
Use ‘mkdir’ command on remote

sftp> mkdir linuxpcifx

Use ‘lmkdir’ command on local system

sftp> lmkdir linuxpcifx

To remove the file

sftp> rm somefilename
sftp> rmdir somefilename

Change directory.
Use cd command on remote system

sftp> cd linuxpcfix

Use lcd command on local system

sftp> lcd linuxpcfix

Disconnect SFTP connection.

sftp> exit

Finally SFTP command is very useful tool for users and system admins for managing files and directories on remote linux servers. SFTP provides secure data transmission over the public internet.


I am founder and webmaster of www.linuxpcfix.com and working as a Sr. Linux Administrator (Expertise on Linux/Unix & Cloud Server) and have been in the industry from last 7 years.

Leave a Reply

Your email address will not be published. Required fields are marked *


Time limit is exhausted. Please reload the CAPTCHA.

Categorized Tag Cloud