Linux uses the sftp command to transfer files. Step

  

sftp is a command in the Linux system. The number of users is not much, so many users do not know the purpose of the sftp command. The sftp command can be used to transfer files, which is similar to ftp. The following small series will introduce you to the way Linux uses the sftp command to transfer files.

1. landing approach used:

Format: sftp "user" @ "host"

is connected via sftp "host", the default port 22, Specify the user "user".

2. View sftp support commands

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

sftp"help

(where the command is “l” indicates local execution, others indicate execution on the remote host that is logged in.)

3.Basic use

sftp is mainly used to transfer files, including uploading files (from This machine goes to the remote host) and downloads the file (from the remote host to the local machine).

(1) File Download

get [-Ppr] remote [local]

For example: 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]

For example: put /home/liu/Software/RHEL_5.5\\ x86_64.iso /Home/xudong/Blog/

Transfer the ios file from the local /home/liu/Software/directory to the /home/xudong/Blog/directory of the remote login host.

(3) Other commands

There are several commands that can be used, such as ls, lls; cd, lcd; pwd, lpwd, etc. See the help output for details.

sftp is the secure file transfer program, which is based on ssh and is very convenient for transferring documents between two Linux systems.

To use sftp to pass documents, you should first open the ssh service on the server side. If it is not open, you can usually open it with the following command:

# /etc/init.d/sshd start< Br>

Then you can log in to the server through the sftp client for document delivery, as follows:

$ sftp [-oPort=port_number] username@server_ip[:file1 file2 . . . ]

Parameter Description:

-o is used to pass parameters to ssh, such as -oPort=222, which tells ssh to use port 222 of the connection server instead of the default port 22. This can be useful when you encounter a change in the default port 22 of the ssh service on the server side.

The following file1, file2 represents the file name, and can also be a directory. When no file is specified, an interactive interface is opened, and the document can be passed by command under the interactive interface.

For example:

$ sftp -o port = 222 [email protected]

Command Description:

Under the interface of the sftp command There are many commands that can be used, such as: cd, ls, pwd, bye, chmod, chgrp, chown, df, get, help, mkdir, and so on. Of course, these commands are all for server-side operations, some of which can be implemented locally under the prefix of l. For example, the lpwd command prints the local current working directory (that is, the current working directory before connecting 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 will push the local file or directory to the server; the get command will pull the server-side file or directory "draw".

The above is the introduction of Linux using the sftp command to transfer files. Compared with ftp, the sftp command is more secure. It is recommended to use the sftp command to transfer files.

Copyright © Windows knowledge All Rights Reserved