sftp常用命令介绍

sftp是Secure FileTransferProtocol的缩写,安全文件传送协议。可以为传输文件提供一种安全的加密方法。sftp与 ftp有着几乎一样的语法和功能。SFTP为 SSH的一部分,是一种传输档案至Blogger伺服器的安全方式。其实在SSH软件包中,已经包含了一个叫作SFTP(Secure File TransferProtocol)的安全文件传输子系统,SFTP本身没有单独的守护进程,它必须使用sshd守护进程(端口号默认是22)来完成相应的连接操作,所以从某种意义上来说,SFTP并不像一个服务器程序,而更像是一个客户端程序。SFTP同样是使用加密传输认证信息和传输的数据,所以,使用SFTP是非常安全的。但是,由于这种传输方式使用了加密/解密技术,所以传输效率比普通的FTP要低得多,如果您对网络安全性要求更高时,可以使用SFTP代替FTP。

SFTP命令常用选项sftp即secure ftp,是一个交互式文件传输程式。它类似于ftp,但它进行加密传输,比FTP有更高的安全性。
在这里插入图片描述

1. sftp user@ip

  • 你要用sftp, 当然得登录到sftp服务器啊, 在linux的shell中执行上面的命令后, linux shell会提示用户输入密码, 我们就输入password吧。 这样就成功建立了sftp连接。

2. help

  • 建立连接后, linux shell中的$编程了sftp>, 这也对。 现在执行以下help, 可以看看sftp支持哪些命令。
// A code block
Available commands:
ascii                          Set transfer mode to ASCII
binary                         Set transfer mode to binary
cd path                        Change remote directory to 'path'
detail remote-path             Display system information about remote
                                 file or folder
ldetail local-path             Display system information about local
                                 file or folder
lcd path                       Change local directory to 'path'
chgrp group path               Change group of file 'path' to 'group'
chmod mode path                Change permissions of file 'path' to 'mode'
chown owner path               Change owner of file 'path' to 'owner'
exit                           Quit sftp
help                           Display this help text
include filename               Include commands from 'filename'
                                 Alternate: < filename
get [-a | -b] remote-path      Download file
                                 force ascii (-a) or binary (-b) mode
ln [-s] existingpath linkpath  Hardlink / symlink remote file
ls [options] [path]            Display remote directory listing
lls [options] [path]           Display local directory listing
mkdir path                     Create remote directory
lmkdir path                    Create local directory
mv oldpath newpath             Move remote file
open [user@]host[:port]        Connect to remote host
put [-a | -b] local-path       Upload file
                                 force ascii (-a) or binary (-b) mode
pwd                            Display remote working directory
lpwd                           Print local working directory
quit                           Quit sftp
rmdir path                     Remove remote directory
lrmdir path                    Remove local directory
rm path                        Delete remote file
lrm path                       Delete local file
su username                    Substitutes the current user
                                 This is only supported with VShell for 
                                 Windows 3.5 or later.
type [transfer-mode]           Display or set file transfer mode
view remote-path               Download and open file
version                        Display protocol version

3. pwd和lpwd

  • pwd是看远端服务器的目录, 即sftp服务器默认的当前目录。 lpwd是看linux本地目录。

4. ls和lls

  • ls是看sftp服务器下当前目录下的东东, lls是看linux当前目录下的东东。

5. put a.txt

  • 这个是把linux当前目录下的a.txt文件上传到sftp服务器的当前目录下。
    在这里插入图片描述

6. get b.txt

  • 这个是把sftp服务器当前目录下的b.txt文件下载到linux当前目录下。
    在这里插入图片描述

7. !command

  • 这个是指在linux上执行command这个命令, 比如!ls是列举linux当前目录下的东东, !rm a.txt是删除linux当前目录下的a.txt文件。
  • 这个命令非常非常有用, 因为在sftp> 后输入命令, 默认值针对sftp服务器的, 所以执行rm a.txt删除的是sftp服务器上的a.txt文件, 而非本地的linux上的a.txt文件。

8. exit和quit

  • 退出。

总之, 连接后, 有一个help命令, 足矣足矣。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值