Example of SFTP command transfer file under Linux

Source: Internet
Author: User
Tags ssh port number


SFTP is an interactive file transfer program. It is similar to FTP, but it carries on the encrypted transmission, has the higher security than the FTP.

1. Common Landing Method:

Format: SFTP <user>@

Connect

2. View SFTP supported commands

Use the help command to view supported commands, such as:

Sftp>help

(where "L" is preceded by a command that indicates local execution, and other representations are performed on the remote host being logged on)

3. Basic use

SFTP is mainly used to transfer files, including uploading files (from native to remote host), downloading files (from remote hosts to native computers).

(1) File download

Get [-PPR] remote [local]

such as: Get Test.cpp./project/

Download the file Test.cpp from the remote current directory to the project folder in the local current directory.

(2) File upload

Put [-PPR] local [remote]

such as: Put/home/liu/software/rhel_5.5\ x86_64.iso/home/xudong/blog/

Transfer the iOS files in the local/home/liu/software/directory to the/home/xudong/blog/directory of the remote landing host.

(3) Other orders

You can use commands or a few, such as LS, LLS;CD, lcd;pwd, Lpwd, and so on. See the help output specifically.

SFTP is the secure file transfer program, which is based on SSH and is handy for passing documents between two Linux systems.

To deliver documents using SFTP, you should first turn on the SSH service on the server side, and if not, you can generally open it by using the following command:


#/etc/init.d/sshd Start

You can then perform document delivery operations on the client via the SFTP login server, as follows:

$ SFTP [-oport=port_number] username@server_ip[:file1 file2 ...]

Parameter description:
-O, which is used to pass parameters to ssh, such as-oport=222, tells SSH to use port 222, not the default 22 port, to connect to the server. This is useful when you encounter a server-side default port number 22nd change.

The following file1, file2 represent the filename, or it can be a directory. An interactive interface is opened when no files are specified, and a command is used to deliver the document under the interactive interface.

Such as:


$ sftp-o Port = 222 User@www.111cn.net

Command Description:

In the interactive interface of the SFTP command, there are many commands available, such as: CDs, LS, PWD, bye, chmod, CHGRP, Chown, DF, GET, help, mkdir, and so on. Of course, these commands are for server-side operations, and some of these commands can be implemented locally with the L prefix. For example, the LPWD command prints the local current working directory (that is, the current working directory before the connection sftp). Two of these commands are used to exchange documents, they are get and put commands, as follows:


> Put Local_path [Remote_path]

> Get Remote_path [Lcoal_path]
The put command pushes the local file or directory to the server side, and the GET command pulls the server-side file or directory down.

Basically, the SFTP command knows so much about the basics that more can be found in men's help.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.