FTP、SFTP、LFTP文件传输协议使用

文件传输协议

文件传输协议

ftp

ftp - 文件传输协议,现在有更安全的sftp,以及更强大的lftp;命令基本相同,真的需要使用ftp可以使用man ftp

以及help再查看即可。

sftp

Sftp - OpenSSH 安全文件传输

语法:

sftp [-46AaCfNpqrv] [-B buffer_size] [-b batchfile] [-c cipher] [-D sftp_server_path] [-F ssh_config] [-i identity_file] [-J destination] [-l limit] [-o ssh_option] [-P port] [-R num_requests] [-S program] [-s subsystem | sftp_server] destination

连接命令:

# 不指定用户默认当前用户
sftp ip
# 指定用户
sftp 用户名@IP
# 指定端口
sftp -P port 用户名@IP
# destination也可以是一个url sftp://[user@]host[:port][/path]
sftp sftp://ip:port/test

连接远端服务器(可使用ssh免密连接):

sftp ip

连接成功后,本地执行命令:

!cd /home/zsl0

等价于

lcd /home/zsl0

远端执行命令:

cd /home

向远端传输test文件:

put test

向远端传输files文件夹:

put -r files

操作命令:

Available commands:
bye                                Quit sftp
cd path                            Change remote directory to 'path'
chgrp [-h] grp path                Change group of file 'path' to 'grp'
chmod [-h] mode path               Change permissions of file 'path' to 'mode'
chown [-h] own path                Change owner of file 'path' to 'own'
df [-hi] [path]                    Display statistics for current directory or
                                   filesystem containing 'path'
exit                               Quit sftp
get [-afpR] remote [local]         Download file
help                               Display this help text
lcd path                           Change local directory to 'path'
lls [ls-options [path]]            Display local directory listing
lmkdir path                        Create local directory
ln [-s] oldpath newpath            Link remote file (-s for symlink)
lpwd                               Print local working directory
ls [-1afhlnrSt] [path]             Display remote directory listing
lumask umask                       Set local umask to 'umask'
mkdir path                         Create remote directory
progress                           Toggle display of progress meter
put [-afpR] local [remote]         Upload file
pwd                                Display remote working directory
quit                               Quit sftp
reget [-fpR] remote [local]        Resume download file
rename oldpath newpath             Rename remote file
reput [-fpR] local [remote]        Resume upload file
rm path                            Delete remote file
rmdir path                         Remove remote directory
symlink oldpath newpath            Symlink remote file
version                            Show SFTP version
!command                           Execute 'command' in local shell
!                                  Escape to local shell
?                                  Synonym for help

lftp

Left - 复杂的文件传输程序

连接命令:

# 指定账号密码连接
lftp sftp://用户名:密码@IP:端口
lftp -u 用户名,密码@ sftp://IP
lftp -u 用户名,密码@ ftp://IP

# lftp中建立连接
lftp

# 指定协议 端口 账号密码(可使用ssh免密连接) 
open sftp://ip -p port -u user:password
# 等价于
open sftp://ip -p port
login user password

一行命令拉去文件:

lftp -c ‘open sftp://ip:port -u user:password; cd /home/zsl0; get kubernetes.conf;’

拉去文件夹内文件:

lftp -c ‘open sftp://ip:port; cd /home/files; lcd /Users/zsl0/files; mirror --no-recursion -I *.txt;’

其它命令:

lftp :~> help
    !<shell-command>                     
    (commands)                           
    alias [<name> [<value>]]
    attach [PID]                         
    bookmark [SUBCMD]                    
    cache [SUBCMD]
    cat [-b] <files>                     
    cd <rdir>                            
    chmod [OPTS] mode file...
    close [-a]                           
    [re]cls [opts] [path/][pattern]      
    debug [OPTS] [<level>|off]
    du [options] <dirs>                  
    edit [OPTS] <file>                   
    exit [<code>|bg]
    get [OPTS] <rfile> [-o <lfile>]      
    glob [OPTS] <cmd> <args>             
    help [<cmd>]
    history -w file|-r file|-c|-l [cnt]  
    jobs [-v] [<job_no...>]              
    kill all|<job_no>
    lcd <ldir>                           
    lftp [OPTS] <site>                   
    ln [-s] <file1> <file2>
    ls [<args>]                          
    mget [OPTS] <files>                  
    mirror [OPTS] [remote [local]]
    mkdir [OPTS] <dirs>                  
    module name [args]                   
    more <files>
    mput [OPTS] <files>                  
    mrm <files>                          
    mv <file1> <file2>
    mmv [OPTS] <files> <target-dir>      
    [re]nlist [<args>]                   
    open [OPTS] <site>
    pget [OPTS] <rfile> [-o <lfile>]     
    put [OPTS] <lfile> [-o <rfile>]      
    pwd [-p]
    queue [OPTS] [<cmd>]                 
    quote <cmd>                          
    repeat [OPTS] [delay] [command]
    rm [-r] [-f] <files>                 
    rmdir [-f] <dirs>                    
    scache [<session_no>]
    set [OPT] [<var> [<val>]]            
    site <site_cmd>                      
    source <file>
    torrent [OPTS] <file|URL>...         
    user <user|URL> [<pass>]             
    wait [<jobno>]

如上查看命令怎么使用时,使用 help <command>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值