用途说明
sftp命令可以通过ssh来上传和下载文件,是常用的文件传输工具,它的使用方式与ftp类似,但它使用ssh作为底层传输协议,所以安全性比ftp要好得多。
常用方式
格式:sftp <host>
通过sftp连接<host>,端口为默认的22,用户为Linux当前登录用户。
格式:sftp -oPort=<port> <host>
通过sftp连接<host>,指定端口<port>,用户为Linux当前登录用户。
格式:sftp <user>@<host>
通过sftp连接<host>,端口为默认的22,指定用户<user>。
格式:sftp -oPort=<port> <user>@<host>
通过sftp连接<host>,端口为<port>,用户为<user>。
sftp> help
可用命令:
cd 路径 更改远程目录到“路径”
lcd 路径 更改本地目录到“路径”
chgrp group path 将文件“path”的组更改为“group”
chmod mode path 将文件“path”的权限更改为“mode”
chown owner path 将文件“path”的属主更改为“owner”
exit 退出 sftp
help 显示这个帮助文本
get 远程路径 下载文件
ln existingpath linkpath 符号链接远程文件
ls [选项] [路径] 显示远程目录列表
lls [选项] [路径] 显示本地目录列表
mkdir 路径 创建远程目录
lmkdir 路径 创建本地目录
mv oldpath newpath 移动远程文件
open [用户@]主机[:端口] 连接到远程主机
put 本地路径 上传文件
pwd 显示远程工作目录
lpwd 打印本地工作目录
quit 退出 sftp
rmdir 路径 移除远程目录
lrmdir 路径 移除本地目录
rm 路径 删除远程文件
lrm 路径 删除本地文件
symlink existingpath linkpath 符号链接远程文件
version 显示协议版本
[root@localhost ~]# sftp 192.168.1.181 Connecting to 192.168.1.181... root@192.168.1.181's password: sftp> ls -l *.gz -rw-r--r-- 0 0 0 7770116 May 14 2010 mini.tar.gz sftp> lls *.gz cn.tar.gz ct08.min.tar.gz files.20101216a.tar.gz sftp> get mini.tar.get Couldn't stat remote file: No such file or directory File "/root/mini.tar.get" not found. sftp> ^[[A Invalid command. sftp> get mini.tar.gz Fetching /root/mini.tar.gz to mini.tar.gz /root/mini.tar.gz 100% 7588KB 7.4MB/s 00:01 sftp> lls mini.tar.gz -l -rw-r--r-- 1 root root 7770116 04-03 15:20 mini.tar.gz sftp> quit
# sftp -oPort=33333 admin@192.168.1.1 //带端口登录
评论(0)
暂无评论