【Linux】SFTP的用法

sftp是什么?

sftp(Secure File Transfer Protocol)安全的文件传输协议。

sftp是ssh的一部分,使用sftp时也是通过ssh建立一个可靠的通信线路来进行文件传输的。

 

sftp下可用的指令:

ls、mkdir、rmdir、pwd、chgrp、chown、chmod、ln、rm、exit、bye、quit

对于客户端可用的指令:

lcd(切换目录)、lls、lpwd

上传/下载文件的格式

将文件由本机上传到远程主机:put [本机文件] ,文件会存储到当前远程主机的目录下。

将文件由远程主机下载下来:get  [远程主机文件],文件会存储在当前本机所在的目录当中。

使用windows的xshell连接sftp:

[C:\~]$ sftp root@172.24.8.128

sftp:/root> put E:\test.txt   将windows下的文件上传至linux的当前目录下(无法上传目录也无法指定目录路径)

sftp:/root> get ceshi   将linux当前目录的文件下载至windows当前的目录,lcd可查看当前客户端目录(无法上传目录也无法指定目录路径)

使用linux客户端连接sftp:

[root@client ~]# sftp root@172.24.8.128                                 

(1)将客户端的client目录上传至服务端的test目录

sftp> pwd

Remote working directory: /test

sftp> lpwd

Local working directory: /client

使用put命令将客户端文件上传至服务端:

sftp> mkdir /test/client

sftp> put -r /client/ /test

Uploading /client/ to /test/client

Entering /client/

/client/upload                                                   100%    5     0.0KB/s   00:00   

检查文件: 

(2)将服务端目录linuxtest下载到客户端client目录

sftp> pwd

Remote working directory: /linuxtest

sftp> lpwd

Local working directory: /client

 使用get命令将服务端文件下载到客户端上:

sftp> get -r /li

lib/        lib64/      linuxtest/ 

sftp> get -r /linuxtest/ /client

Fetching /linuxtest/ to /client/linuxtest

Retrieving /linuxtest

/linuxtest/download                                              100%    5     0.0KB/s   00:00   

 检查文件:

sftp> lls /client

linuxtest  upload

注:上传和下载命令用法一致

 

 

 

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值