信息发布→ 登录 注册 退出

linux中远程服务器上传输文件的10个sftp命令示例

发布时间:2025-07-21

点击量:

ssh session

  1. 如何连接到 SFTP
    [root@rumenz ~]# sftp -P 22 zhaoShanHe@192.168.0.100
    Connecting to 192.168.0.100...
    zhaoShanHe@192.168.0.100's password:
    sftp>
> sftp -P 22 -i ~/.ssh/id_rsa zhaoShanHe@192.168.0.100
  1. 帮助

    sftp> ?
    Available commands:
    cd path                       Change remote directory to 'path'
    lcd path                      Change local directory to 'path'
    chgrp grp path                Change group of file 'path' to 'grp'
    chmod mode path               Change permissions of file 'path' to 'mode'
    chown own path                Change owner of file 'path' to 'own'
    help                          Display this help text
    get remote-path [local-path]  Download file
    lls [ls-options [path]]       Display local directory listing
    ln oldpath newpath            Symlink remote file
    lmkdir path                   Create local directory
    lpwd                          Print local working directory
    ls [path]                     Display remote directory listing
    lumask umask                  Set local umask to 'umask'
    mkdir path                    Create remote directory
    put local-path [remote-path]  Upload file
    pwd                           Display remote working directory
    exit                          Quit sftp
    quit                          Quit sftp
    rename oldpath newpath        Rename remote file
    rmdir path                    Remove remote directory
    rm path                       Delete remote file
    symlink oldpath newpath       Symlink remote file
    version                       Show SFTP version
    !command                      Execute 'command' in local shell
    !                             Escape to local shell
    ?                             Synonym for help
  2. 检查当前工作目录

    sftp> lpwd
    Local working directory: /
    sftp> pwd
    Remote working directory: /zhaoyanfei/

lpwd – 显示本地系统上的当前目录 pwd – 显示 ftp 服务器上的当前目录

  1. 使用 sftp 列出文件 远程
    sftp> ls

本地

sftp> lls
  1. 使用 sftp 上传文件

    sftp> put local.profile
    Uploading local.profile to /rumenz/local.profile
  2. 使用 sftp 上传多个文件

    sftp> mput *.xls
  3. 使用 sftp 下载文件

    sftp> get SettlementReport_1-10th.xls
    Fetching /zhaoYanFei/SettlementReport_1-10th.xls to SettlementReport_1-10th.xls
sftp> mget *.xls
  1. 在 sftp 中切换目录 远程
    sftp> cd test
    sftp>

本地

sftp> lcd Documents
  1. 使用 sftp 创建目录

    sftp> mkdir test
    sftp> lmkdir Documents
  2. 使用 sftp 删除目录

    sftp> rm Report.xls
    sftp> rmdir sub1
  3. 退出 sftp Shell

    sftp> exit
    [root@sftp ~]# 
    Shell exited with status 1
    sftp>
标签:# linux  # ai  # Session  # ssh  # 多个  # 连接到  # 上传文件  # 器上  # 上传  # owner  # chown  # mode  # Display  # permissions  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!