Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to transfer files by using sftp command in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "Linux how to use sftp command to transfer files", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Linux how to use sftp commands to transfer files" bar!

Sftp is a command in the Linux system, the number of users is small, so many users do not know the purpose of the sftp command, sftp command can be used to transfer files, and ftp is somewhat similar, the following editor will introduce Linux to use the sftp command to transfer files.

1. Common login methods:

Format: sftp "user" @ "host"

Connect to "host" through sftp with the default port of 22 and specify the user "user".

two。 View commands supported by sftp

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

Sftp "help

(the command is preceded by "l" for local execution, and the other means executed on the remote host to which the command is logged in.)

3. Basic use

Sftp is mainly used to transfer files, including uploading files (from the local host to the remote host) and downloading files (from the remote host to the local host).

(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]

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 orders

There are several commands that can be used, such as ls, lls;cd, lcd;pwd, lpwd, and so on. Check out the help output in detail.

Sftp is secure file transfer program, which is based on ssh, and it is very convenient to transfer documents between two Linux systems.

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

# / etc/init.d/sshd start

You can then log in to the server through sftp on the client side 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 222to connect to the server instead of the default port 22. This is useful when the server changes the default port 22 of the ssh service.

The following file1 and file2 represent the file name, or a directory. An interactive interface opens when no file is specified, under which the document can be transferred through commands.

Such as:

$sftp-o port = 222user@www.xitongzhijia.net

Command description:

In the sftp command interface, there are many commands available, such as: cd, 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 them can operate on the ground floor with the l prefix. For example, the lpwd command prints the local current working directory (that is, the current working directory before connecting to 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, while the get command "pulls" the server-side file or directory.

Thank you for your reading, the above is the content of "how Linux uses sftp commands to transfer files". After the study of this article, I believe you have a deeper understanding of how Linux uses sftp commands to transfer files, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report