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

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

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

请参考:

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

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

 

FTP 命令的使用 Linux 第1张

                                                  主动连接

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.

                        FTP 命令的使用 Linux 第2张

                                                     被动连接

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 确定服务器文件夹。

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

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄