zoukankan      html  css  js  c++  java
  • FTP 命令的使用

    最近需要使用 ftp 工具,所以借此机会来进行整理以下具体的内容:

    具体什么是ftp, ftp 能干什么?

    请参考:

    https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/s1-ftp

    http://cn.linux.vbird.org/linux_server/0410vsftpd.php

    重点理解:主动联机 与 被动联机 两种模式中,端口的选择。

                                                      主动连接

    active mode

           Active mode is the original method used by the FTP protocol for transferring data to the client application. When an active-mode data transfer is initiated by the FTP client, the server opens a connection from port 20 on the server to the IP address and a random, unprivileged port (greater than 1024) specified by the client. This arrangement means that the client machine must be allowed to accept connections over any port above 1024. With the growth of insecure networks, such as the Internet, the use of firewalls for protecting client machines is now prevalent. Because these client-side firewalls often deny incoming connections from active-mode FTP servers, passive mode was devised.

                            

                                                         被动连接

    passive mode

           Passive mode, like active mode, is initiated by the FTP client application. When requesting data from the server, the FTP client indicates it wants to access the data in passive mode and the server provides the IP address and a random, unprivileged port (greater than 1024) on the server. The client then connects to that port on the server to download the requested information.
           While passive mode does resolve issues for client-side firewall interference with data connections, it can complicate administration of the server-side firewall. You can reduce the number of open ports on a server by limiting the range of unprivileged ports on the FTP server. This also simplifies the process of configuring firewall rules for the server.
     
    安装vsftpd 软件:
    ➜  Desktop yum search vsftpd   
    Last metadata expiration check: 5 days, 21:35:37 ago on Tue 26 Jun 2018 04:58:21 PM CST.
    ================================================== Name Exactly Matched: vsftpd ==================================================
    vsftpd.x86_64 : Very Secure Ftp Daemon

    vsftpd 全称为:  Very Secure Ftp Daemon

    vsftpd 配置文件:我们可以使用 man 5 vsftpd.conf 命令,来查找vsftpd 的配置说明。

    FTP 连接与命令:

    1. 登录

    [root@dhcp-65-15 ~]# ftp localhost
    Trying ::1...
    Connected to localhost (::1).
    220 Welcome to blah FTP service.
    Name (localhost:root): yaowen
    331 Please specify the password.
    Password:
    230 Login successful.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp> ls
    229 Entering Extended Passive Mode (|||60063|)
    150 Here comes the directory listing.
    drwxr-xr-x    4 1000     1000         4096 Jun 26 08:50 Desktop
    drwxr-xr-x    2 1000     1000         4096 Jun 27  2017 Documents
    drwxr-xr-x    2 1000     1000         4096 May 29 02:09 Downloads
    drwxrwxr-x    3 36       36           4096 Jun 27 02:59 ISO
    drwxr-xr-x    4 36       36           4096 Jun 25 08:41 NFS4
    drwxr-xr-x    2 1000     1000         4096 Jun 27  2017 Pictures
    drwxr-xr-x    2 1000     1000         4096 Jun 27  2017 Public
    drwxr-xr-x    2 1000     1000         4096 Jun 27  2017 Templates
    drwxr-xr-x    2 1000     1000         4096 Jun 27  2017 Videos
    226 Directory send OK.
    ftp> 

     2. 如果没有ftp 命令,则进行安装

    [root@yaowenxu Desktop]# yum install ftp

    3. ftp 支持的命令

    使用 help 或者 ? 来进行查看当前服务所支持的命令

    ftp> ?
    Commands may be abbreviated.  Commands are:
    
    !        debug        mdir        sendport    site
    $        dir        mget        put        size
    account        disconnect    mkdir        pwd        status
    append        exit        mls        quit        struct
    ascii        form        mode        quote        system
    bell        get        modtime        recv        sunique
    binary        glob        mput        reget        tenex
    bye        hash        newer        rstatus        tick
    case        help        nmap        rhelp        trace
    cd        idle        nlist        rename        type
    cdup        image        ntrans        reset        user
    chmod        lcd        open        restart        umask
    close        ls        prompt        rmdir        verbose
    cr        macdef        passive        runique        ?
    delete        mdelete        proxy        send

    我们可以使用 ftp 利用交互式的方式来进行与 ftpd 服务器来进行交互。

    我们 可以使用 get 下载文件,使用 put 上传文件;

    使用 lcd 确定本地文件夹,使用pwd 确定服务器文件夹。

    保持更新,转载请注明出处。

  • 相关阅读:
    Linux编程 22 shell编程(输出和输入重定向,管道,数学运算命令,退出脚本状态码)
    mysql 开发进阶篇系列 46 物理备份与恢复( xtrabackup的 选项说明,增加备份用户,完全备份案例)
    mysql 开发进阶篇系列 45 物理备份与恢复(xtrabackup 安装,用户权限,配置)
    mysql 开发进阶篇系列 44 物理备份与恢复( 热备份xtrabackup 工具介绍)
    Linux编程 21 shell编程(环境变量,用户变量,命令替换)
    Linux编程 20 shell编程(shell脚本创建,echo显示信息)
    mysql 开发进阶篇系列 43 逻辑备份与恢复(mysqldump 的基于时间和位置的不完全恢复)
    Linux编程 19 编辑器(vim 用法)
    (网页)angularjs中的interval定时执行功能(转)
    (网页)在SQL Server中为什么不建议使用Not In子查询(转)
  • 原文地址:https://www.cnblogs.com/xuyaowen/p/ftp_info.html
Copyright © 2011-2022 走看看