OpenSSH Configuration and Usage Part 3

Hi guys I hope you enjoyed both parts of SSH this is the final part of SSH which is based on SFTP. In this tutorial we will cover how to use SFTP commands we have already discussed how to configure SFTP server in our previous tutorial. In this tutorial we will learn how to use ls,lls,pwd,lpwd,mkdir,rmdir,put,get,mput and mget commands

Feb0916-19usd-program728x90

SSH File Transfer Protocol

A network protocol that provides file transfer and manipulation functionality over any reliable DataStream. It is typically used with the SSH-2 Protocol to provide secure file transfer. (Intended to be usable with other protocol as well)

Capabilities

The SFTP allows for a range of operations on remote files. SFTP Client’s extra capabilities compared to SCP client including;

  • Resuming interrupted transfers
  • Directory listings
  • Remote file removal

For the same reason it is reasonable to implement a GUI SFTP client, but not a GUI SCP client.

Log on using SFTP

We want to log on to sftp by using command sftp. Syntax  sftp username@hostname/IP

[Server@faraz ~]$ sftp [email protected]
[email protected]'s password:
Connected to 192.168.56.103.
sftp>

Commands on remote/local System

Once you are logged on to the remote system, normal commands run and will responds you for the system on which you are logged on (Remote system). For issuing commands for local system put “l” (small L) before any normal commands.

List contents of remote system by using command ls.

sftp> ls
Desktop             Documents           Download            Downloads
Music               Pictures            Public              Templates
Videos              historysave.txt     newstring.file      ssh.config
testfile.txt
sftp>

List contents of local system by using command lls.

sftp> lls
lls
1234       Downloads        historysave.txt   Pictures   testfile.txt
Desktop    testf            Music             Public     Videos
Documents  newstring.file   Templates
sftp>

To check present working directory on remote system by using command pwd.

sftp> pwd
Remote working directory: /home/Client
sftp>

For local system to check working directory by using command lpwd.

sftp> lpwd
Local working directory: /home/Server
sftp>

Change directory on remote system by using command cd.

sftp> cd Documents/
sftp> pwd
Remote working directory: /home/Client/Documents
sftp>

For local system change directory by using command lcd.

sftp> lcd Desktop
lcd Desktop
sftp> lpwd
Local working directory: /home/Server/Desktop
sftp>

Make directory on remote system by using command mkdir and for remove directory by using command rmdir.

sftp> mkdir test123
sftp> ls
Desktop             Documents           Download            Downloads
Music               Pictures            Public              Templates
Videos              historysave.txt     ssh.config          test123
testfile.txt        

sftp> rmdir test123
sftp> ls
Desktop             Documents           Download            Downloads
Music               Pictures            Public              Templates
Videos              historysave.txt     ssh.config          testfile.txt        
sftp>

Upload file from local system to remote system by using command put.

For multiple files use mput. Syntax mput *.txt/*.pdf (do it yourself).

sftp> ls
Desktop             Documents           Download            Downloads
Music               Pictures            Public              Templates
Videos              historysave.txt     newstring.file      ssh.config
testfile.txt

sftp> lls
Desktop    Downloads  Music     Public     upload.txt
Documents  Faraz      Pictures  Templates  Videos

sftp> put upload.txt
Uploading upload.txt to /home/Client/upload.txt
upload.txt                                    100%  217     0.2KB/s   00:00
sftp>

Now want to download file from remote to local system by using command get. For multiple files use mget. Syntax mget *.txt/*.pdf (do it yourself).

sftp> get newstring.file
get newstring.file
Fetching /home/Client/newstring.file to newstring.file
/home/Client/newstring.file                    100%   76     0.1KB/s   00:00

sftp> lls
Desktop    Downloads  Music           Pictures  Templates   Videos
Documents  Faraz      newstring.file  Public    upload.txt
sftp>

Now I want to close the session from sftp by using command exit or bye.

sftp> exit
exit
[Server@faraz ~]$

I hope you enjoyed SFTP commands and now you must be comfortable using sftp . There are so many tools with GUI to upload and download files local/remote systems like FileZilla, FireFTP etc. Feel free to explore these GUI tools. Let us know your thoughts about tutorial and suggestion to improve the quality of our tutorials

Thanks

SUBSCRIBE OUR NEWSLETTER
I agree to have my personal information transfered to MailChimp ( more information )
Join us by subscribing to our newsletter and learn IT subjects for free
We hate spam. Your email address will not be sold or shared with anyone else.