sftp 使用介绍

发布时间: 更新时间: 总字数:629 阅读时间:2m 作者:IP:上海 网址

在Linux中采用sftp(Secure File Transfer Protocol)为传输文件提供一种安全的网络的加密方法。本文介绍如何使用sftp做文件传输(与ftp基本类似)。

连接远程linux

sftp <user>@<ip>

操作远程服务器

  • ls 显示远端主机的列表
  • cd 切换远程的工作目录
  • pwd 显示远程的工作目录

操作本地服务器

  • lls 显示本地主机的列表
  • lcd 切换本地的工作目录
  • lpwd 查看本地目录信息

上传下载文件

  • get 从远程服务器下载数据(单个文件)
  • mget 下载多个文件
  • put 从本地服务器上传数据(单个文件)
  • mput 上传多个文件

查看帮助

sftp> help
sftp help ...

示例

查看路径

sftp> pwd     # Display remote working directory
Remote working directory: /root
sftp> lpwd    # Print local working directory
sftp> lpwd
Local working directory: /Users/xiexianbin/
sftp>

上传文件

put -r <本地路径>  <远程路径>
sftp> put -r hbxctl /root
Uploading hbxctl to /root/hbxctl
hbxctl                                        100% 2565    20.8KB/s   00:00
sftp>

上传文件夹

put -r <本地文件夹/*>  <远程路径/新建文件夹/>

下载文件

get -r <远程路径> <本地路径>
sftp> get -r /root/themes themes

下载文件夹

get -r <远程路径/文件夹/*>  <本地路径/新建文件夹/>

退出

exit
本文总阅读量 次 本站总访问量 次 本站总访客数