Topics Summary

 

What is the sftp?

  • The sftp is the utility provided by the Linux system to transfer the files from one Linux machine to the Linux machine in the encrypted form.
  • This sftp utility uses the ssh protocol to transfer the files from one system to the another system.

 

We can login as either root user or normal user for sftp. If we logged in as the root user our working directory will be /root on the remote system.

If we logged in as the normal user our working directory will be the home directory of the normal user ex: /home/alex.

 

Connecting to the remote machine as the root user of the remote machine:

To connect the remote machine as the root user of the remote machine use the command as shown below.

[root@sys1 ~]# sftp root@192.168.1.6
Connecting to 192.168.1.6...
root@192.168.1.6's password:
sftp>

 

After we established the connection or prompt will be changed.check the present working directory now.

sftp> pwd
Remote working directory: /root
sftp>

 

Sub Commands Used for sftp:

CommandDescription
ExitQuit sftp session
GetDownload file
LcdChanging the local directory path
LlsList the local directory files
LmkdirCreating the local directory
LpwdPrint local working directory
LsList the remote directory files
LumaskSet the local umask
PutTo upload the file
PwdTo print remote working directory
Version Show sftp version
?To show help

 

Downloading the file from local machine from the remote machine:

After login to the remote machine choose the file you want to down load

sftp> pwd
Remote working directory: /root
sftp> ls
Desktop             Documents      Downloads
Music               Pictures       Public
Templates           Videos         anaconda-ks.cfg.new
core.2841.new       install.log    install.log.syslog.new
ith ithhard*.new    ithonors
ithonors2*.new      ithonours2.new ithonours3.new
ithsoft sapbasis.new sapbi.new
sapmb.new technology.new

 

In the above output the highlighted file I am going to download that is sapbi.new

sftp> get sapbi.new
Fetching /root/sapbi.new to sapbi.new
/root/sapbi.new      100%    51    0.1KB/s    00:00

 

Check the file that can be downloaded into our machine or not.

sftp> lls
1    5                Documents    install.log.syslog  mysql    sapbi.new
2    anaconda-ks.cfg  Downloads    ith1                passwd   Templates
3    #anand#          ebclearn     ithonours1          Pictures Videos
4    Desktop          install.log  Music               Public

 

From the above output the file is success filly downloaded to our machine