sftp命令

您所在的位置:网站首页 sftp命令行 sftp命令

sftp命令

#sftp命令| 来源: 网络整理| 查看: 265

linux sftp 命令

linux sftp 命令

File Transfer Protocol is a very popular protocol for transferring files between hosts. FTP is a fast and practical protocol not secure. In old times security was no problem but into 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 at usage and examples of SFTP. Windows alternative for sftp client is Putty SFTP or Psftp which is provided by putty tools.

文件传输协议是一种非常流行的协议,用于在主机之间传输文件。 FTP是一种快速且实用的协议,不安全。 在过去,安全是没有问题的,但是在当今世界,安全至关重要。 因此,开发了新的协议和方法以使类似FTP的操作更加安全。 安全FTP或SFTP是为安全文件传输而开发的协议。 SFTP通过SSH协议工作,并提供FTP的功能和特性。 SSH默认在端口22 / TCP上运行。 在本教程中,我们将研究SFTP的用法和示例。 Windows替代sftp客户端的方法是Putty SFTP或Puts工具提供的Psftp。

句法 (Syntax)

sftp command has the following command.

sftp命令具有以下命令。

sftp [[email protected]]host[:file ...]

OR

要么

sftp [[email protected]]host[:dir[/]]

OR

要么

sftp -b batchfile [[email protected]]host 连接到Sftp (Connect To Sftp)

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

使用sftp的第一步是连接服务器。 如前所述,sftp使用ssh协议,并且将与ssh服务器建立连接。 身份验证是根据服务器的ssh连接配置完成的,该配置通常是用户名,密码身份验证。

$ sftp ubu1

Or different user name can be explicitly defined

或者可以明确定义其他用户名

$ sftp [email protected] Connect To Sftp Connect To Sftp 连接到Sftp 人与帮助Sftp (Man and Help Sftp)

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

要获得更多详细的帮助,有两种方法。 第一个是使用帮助选项的简单快速的方法。

$ sftp -h Man and Help Sftp Man and Help Sftp 人与帮助Sftp $ man sftp Man and Help Sftp Man and Help Sftp 人与帮助Sftp 命令帮助 (Command Help)

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

连接sftp服务器后,该服务器提供的命令如下所示。

? Command Help Command Help 命令帮助

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

如我们所见,有一个命令,例如cd,chgrp,chmod,exit,ls等。我们将在下一个示例中详细查看这些命令。

当前远程工作目录 (Current Working Directory On Remote)

The 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 the current working directory.

当前工作目录是当前活动的路径,所有发出的命令均根据当前工作目录工作。 例如,下载centos.iso时,给定命令将查找当前工作目录。 这就是我们如何获取当前工作目录。

pwd Current Working Directory On Remote Current Working Directory On Remote 当前远程工作目录 当前本地工作目录(Current Working Directory On Local)

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

sftp有一个本地当前工作目录。 默认情况下,下载文件时,文件将下载到本地当前工作目录中。

lpwd 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 by listing them with the list command.

要下载文件,我们应该知道确切的文件名。 准确获取文件名的最佳方法是使用list命令列出它们。

ls List Files On Remote List Files On Remote 列出远程文件 列出本地文件(List Files On Local)

And here how to list on local

以及如何在本地列出

lls 上传文件到远程 (Upload File To Remote)

The upload will send local file or files to the remote system.

上载会将本地文件发送到远程系统。

mput tmux.tar.gz Upload File Upload File 上传文件 将多个文件上传到远程(Upload Multiple Files To Remote)

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

可以按以下方式上传多个文件。 要通过使用文件扩展名进行上传,可以使用通用名称。

mput * Upload Multiple Files Upload Multiple Files 上载多个文件

OR

要么

mput *.bak 将目录上载到远程 (Upload Directory To Remote)

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

如我们所见,前面的示例mput命令仅用于文件。 要上传目录,还有另一个命令要使用。

put -r * Upload Directory To Remote Upload Directory To Remote 将目录上载到远程

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

这会将所有文件和目录放入远程工作目录。

下载文件到本地 (Download File To Local)

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

sftp的另一种流行用法是使用get从远程下载文件。

get tmux.tar Download File Download File 下载文件 将目录下载到本地(Download Directories To Local)

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

使用get命令递归下载目录。 为了递归获取目录和子目录,提供了-r参数,如下所示。

get -r test3 Download Directories Download Directories 下载目录 远程切换目录(Switch Directory On Remote)

The current working directory for remote can be changed with the simple command cd .

可以使用简单的命令cd更改当前的远程工作目录。

cd tmux Switch Directory On Remote Switch Directory On Remote 远程切换目录 在本地切换目录(Switch Directory On Local)

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

本地上的当前工作目录可以像远程上一样进行更改。

lcd .. Switch Directory On Local Switch Directory On Local 在本地切换目录 在远程上创建目录(Create Directory On Remote)

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

可以与Linux操作系统命令mkdir一样在远程sftp服务器上创建目录。

mkdir test Create Directory On Remote Create Directory On Remote 在远程上创建目录 在本地创建目录(Create Directory On Local)

Same as remote but prefixed with l

与远程相同,但以l开头

lmkdir test 远程删除文件 (Remove File On Remote)

The file can be removed from remote sftp server with rm command

可以使用rm命令从远程sftp服务器中删除文件

rm tmux.tar Remove File On Remote Remove File On Remote 远程删除文件 远程删除目录(Remove Directory On Remote)

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

删除目录命令与遥控器上的文件删除命令不同。

rmdir test Remove Directory On Remote Remove Directory On Remote 远程删除目录 出口(Exit)

To exit from sftp shell alternative commands exist.

要退出sftp shell,可以使用替代命令。

!

OR

要么

exit exit exit 出口 LEARN MORE  Mobaxterm Installation and Usage For Windows 了解更多Mobaxterm Windows的安装和使用

翻译自: https://www.poftut.com/linux-sftp-command-examples/

linux sftp 命令



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3