Linux Sftp Command With Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-sftp-command-examples/
PINTEREST
PINTEREST
INSTAGRAM

File Transfer Protocol is very popular protocol for transferring files between hosts. FTP is fast and practical protocol not not secure. In old times security was no problem but in to days world security is important. So new protocols and ways developed to make FTP like operations more secure. Secure FTP or SFTP is a protocol developed for secure file transfers.  SFTP works over SSH protocol and provides abilities and features of FTP. SSH by default runs on port 22/TCP. In this tutorial we will look usage and examples of SFTP. Windows alternative for sftp client is Putty SFTP or Psftp which is provided by putty tools.

Syntax

Sftp tool have following syntax .

OR

OR

Connect To Sftp

First step to used sftp is connecting a server. As stated before sftp uses ssh protocol and connection will be made to ssh server. Authentication done according to the servers ssh connection configuration which generally a username , password authentication.

Or different user name can be explicitly defined

Connect To Sftp

Connect To Sftp

Man and Help Sftp

To get more and detailed help there is two way exists. First one is simple and fast way with help option.

Command Help

After connecting a sftp server the commands provided by this server can be listed like below.

Command Help

Command Help

As we see there is command like cd, chgrp, chmod, exit, ls etc. We will look these commands in detail next examples.

LEARN MORE  Linux Kill Process Tutorial With Examples

Current Working Directory On Remote

Current working directory is the path currently active all issued commands works according to the current working directory. For example to download centos.iso given command will look current working directory. This is how can we get current working directory.

Current Working Directory On Remote

Current Working Directory On Remote

Current Working Directory On Local

There is local current working directory for sftp. When downloading files by default files will be downloaded to the local current working directory.

Current Working Directory On Local

Current Working Directory On Local

List Files On Remote

To download files we should know the exact file names. The best way to get file names exactly is listing them with list command.

List Files On Remote

List Files On Remote

List Files On Local

And here how to list on local

Upload File

Upload will send local file or files to the remote system.

Upload File

Upload File

Upload Multiple Files

Multiple files can be uploaded like below. To upload by using globbing file extension, generic names can be used.

Upload Multiple Files

Upload Multiple Files

OR

Upload Directory To Remote

As we see previous example mput command isonly used for files. To upload directories there is another command to use.

Upload Directory To Remote

Upload Directory To Remote

This will put all files and directories to the remote working directory.

Download File

Another popular usage of sftp is downloading files from remote with get 

Download File

Download File

Download Directories

Downloading directories recursively done with get command. To get directories and sub directories recursively -r parameter is provided like below.

LEARN MORE  How To Cut Existing Network Connection In Linux?

Download Directories

Download Directories

Switch Directory On Remote

Current working directory for remote can be changed with simple command cd 

Switch Directory On Remote

Switch Directory On Remote

Switch Directory On Local

Current working directory on local can be changed similar to the remote.

Switch Directory On Local

Switch Directory On Local

Create Directory On Remote

Directories can be created on remtoe sftp server the same as Linux operating system command mkdir

Create Directory On Remote

Create Directory On Remote

Create Directory On Local

Same as remote but prefixed with l

Remove File On Remote

File can be removed from remote sftp server with rm command

Remove Directory On Remote

Removing directory command is different from file remove command on remote .

Remove Directory On Remote

Remove Directory On Remote

Exit

To exit from sftp shell alternative commands exist.

OR

exit

exit

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-sftp-command-examples/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)