TCP/IP Application File Transfer Protocol (FTP)

Discussion in 'Linux Networking' started by Jarret W. Buse, Nov 19, 2013.

  1. Jarret W. Buse

    Jarret W. Buse Active Member Staff Writer

    Messages:
    142
    Likes Received:
    172
    Trophy Points:
    43
    TCP/IP Application File Transfer Protocol (FTP)

    The versatility of TCP/IP to be run on a variety of systems allows a wide range of possibilities. File Transfer Protocol (FTP) shows how this is possible by allowing file sharing across platforms and systems.

    The File Transfer Protocol (FTP) is a TCP/IP Application and Protocol. FTP was created to allow the transfer of files between hosts which were not running the same Operating System (OS) or physical hardware. For example, files can be shared between different OSs such as a Linux system and a Microsoft Windows system. An example of different physical hardware systems could be a PC and an Apple Mac system.

    Let’s look at the protocol first to better understand the background of FTP.

    Protocol

    FTP is used to allow a file to be copied from one host to another over a TCP/IP network. FTP guarantees delivery by using the Transport Control Protocol (TCP).

    NOTE: Be aware of the existence of Trivial File Transfer Protocol (TFTP) which is connectionless. It is not guaranteed delivery, since it uses the User Datagram Protocol (UDP). The reason for TFTP was to allow for a smaller overhead on diskless workstations that could only store information in Random Access Memory (RAM). The purpose was for the diskless workstations to copy programs to RAM for booting processes since there wasn’t a local disk for storage.

    The protocol allows for the transfer of files and accomplishes this by setting up the connection between the hosts using TCP (or UDP for TFTP). There are two connections required between the hosts.

    1. Data Connection – used to transfer the data between the two hosts (port 21).
    2. Control Connection – used to transfer control commands between the hosts (port 20).
    There are three processes running on the client system and two on the server system as shown in Figure 1.

    NOTE: The server system is not specifically a Server, but is termed a server since it is sharing a resource. The client system is the system on which FTP is initiated.


    TCPIP Application FTP Figure 1.JPG
    FIGURE 1​

    The files are transferred between the Data Connection on the Client and Server side through Port 21. FTP commands are sent through the Client and Server Protocol Interpreter on Port 20. Keep in mind that each connection can transmit or receive information. The Data Connection can send or receive files while the Protocol Interpreter can send or receive FTP commands. The Protocol Interpreter controls the Data Connection by starting and stopping transfers.

    The User Interface on the client side can be command-line or a Graphical User Interface (GUI) to send and view commands to the Protocol Interpreter.

    The Data Connection is also shown as having access to the file system on the respective host. This allows the reading and writing of the files being transferred.

    In some cases, the FTP server side will not allow access to all files by all users. Some or all files may require permissions. In this case, there is a seven step process to authenticate a user:
    1. Session to Server is initiated by Client.
    2. TCP connection is made to Server which responds with “Ready”.
    3. Client receives “Ready” and sends User Name.
    4. Server receives User Name and sends “Need Password”.
    5. Client receives “Need Password” and sends User Password.
    6. Server receives User Password and verifies User Name and Password. If Verified, Server sends “Verified”. If not verified, Server sends “Denied”.
    7. Client opens connection of Server “Verifies” connection. Otherwise, connection is closed.

    NOTE: Keep in mind that the Control Connection is open throughout the FTP connection. The Data Connection is only open while the file is transferred. Once the transfer is complete, the Data Connection is closed. The Data Connection is re-opened when another transfer is started.


    Information sent over the Data Connection is sent in one of three modes:

    1. Stream Mode – Data is sent unstructured, which means there are not typical headers as associated with TCP/IP. With no headers, there is no overhead. The bits are streamed over the connection. This method is usually the default.
    2. Block Mode – The file is split into blocks and encapsulated into TCP/IP frames. The frames are transmitted in the same manner as with any TCP/IP connection.
    3. Compressed Mode – Repeating strings of data are compressed and sent as encapsulated frames as any TCP/IP connection. Files already compressed as ZIP files or other compressed types gain nothing since the files already have repeating strings compressed.
    The Control Connection can handle different Command Groups. There are three Command Groups used to send commands over the Control Connection session on Port 20:
    1. Access Control – Authentication commands for the User to gain access to the files.
    2. Transfer Parameters – Designates specifics on how the file is to be transferred, such as the mode.
    3. FTP Commands – Actual commands to control the transfer, renaming or deleting files.
    Service

    To Install FTP on Linux, go to a Terminal and enter: sudo apt-get install vsftpd.
    After the installation is completed, open the following file: /etc/vsftpd.conf for editing.
    Here you want to look at the following lines:

    anonymous_enable=YES
    write_enable=YES

    The first line allows for anonymous access to the files. The second line allows a client to change local files (this includes uploading files as well).

    Another item to possibly change is the line: “ftpd_banner=Welcome to my Linux FTP Server!”. This changes the banner that the client will see when they connect to your FTP Server. Save the changes and restart the FTP Service by entering: “sudo /etc/init.d/vsftpd restart”. Files accessible by FTP Clients should be placed into the /srv/ftp/ folder.

    Application

    There are a variety of FTP Client Applications available. Some examples include:

    • FireFox
    • Kasablanca
    • KFTPGrabber
    • Gnome Commander
    • FileRunner
    • Konqueror
    • and others

    Attached Files:

    • slide.jpg
      slide.jpg
      File size:
      45.5 KB
      Views:
      102,243
  2. Amol Patil

    Amol Patil New Member

    Messages:
    6
    Likes Received:
    3
    Trophy Points:
    3
    Jarret,
    I want to make a simple FTP server, that would allow my friends to download files from my computer online.
    I am using Cent OS, and I want this as secure as it can be .
    can you please tell ?
    DevynCJohnson likes this.
  3. grim76

    grim76 Active Member Staff Writer

    Messages:
    177
    Likes Received:
    48
    Trophy Points:
    28
    Amol your best bet is to use an sftp server that is chrooted. That really offers the best security.
    Jarret W. Buse and Amol Patil like this.
  4. Jarret W. Buse

    Jarret W. Buse Active Member Staff Writer

    Messages:
    142
    Likes Received:
    172
    Trophy Points:
    43
    Yes, sftp or vsftp would be fine.
    DevynCJohnson likes this.
  5. grim76

    grim76 Active Member Staff Writer

    Messages:
    177
    Likes Received:
    48
    Trophy Points:
    28
    vsftp would still pass data in the clear. vsftp is and FTP server and not an SFTP server. I do think you can setup FTPs (FTP over SSL) with it, but why go to that trouble.
  6. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,162
    Likes Received:
    988
    Trophy Points:
    113
    The "vs" in vsftp stands for "Very Secure". Many websites/servers use vsftp due to its security. (https://security.appspot.com/vsftpd.html)


    @Amol Patil

    Check out this site which explains how to set up vsftp to use SSL and other security measures. (http://wiki.vpslink.com/Configuring_vsftpd_for_secure_connections_(TLS/SSL/SFTP))
    Amol Patil likes this.
  7. grim76

    grim76 Active Member Staff Writer

    Messages:
    177
    Likes Received:
    48
    Trophy Points:
    28
    I agree that vsftp is a good FTP server, but remember unless you are doing SSL you are not encrypting anything. You can be as secure as you want to with vsftpd, but without encryption you are still passing information in the clear.

Share This Page