SIGN IN / UP
    opened image

    File Transfer Protocol (FTP) is a classic, widely accepted method that allows for file exchange between network devices. File Transfer Protocol is extremely efficient in the process of interacting with large volumes of data, as it provides excellent information exchange on servers. Users can seamlessly share documents, transferring them between a local computer and a remote server, making FTP an indispensable tool for developers, system administrators, and many other professionals. Using FTP allows for quick and convenient file management, uploading them to a website or downloading necessary materials.

    Moreover, FTP supports numerous features, such as access control management, which allows for controlling who can view and edit content. This makes it a valuable solution for organizations that require reliable and secure data transmission.

     

    File Transfer Protocol: Advantages of Use

     

    As a universal method of information exchange, the FTP protocol allows for various purposes. For example, it is often used for:

    • Content Management: FTP allows developers to modify and transfer files on servers.

    • Data Duplication: An especially important and useful tool of FTP for servers is the ability to create backups of various information.

    • Working with Files on a Remote Server: When working with a server, there is an opportunity to manage and edit documents.

     

    Step-by-Step Guide to Configuring an FTP Server

     

    To configure an FTP server, we will focus on a widely used FTP server called Very Secure FTP Daemon, also known as vsftpd, renowned for its reliability and security. This example is suitable for Ubuntu and CentOS platforms based on Linux.

     

    Step 1: Installing FTP

    1. Package Update: Before starting the installation, it is necessary to check for updates for all packages. If necessary, perform the update.
      sudo apt update

    2. Installing vsftpd:
      sudo apt install vsftpd -y

     

     

    Step 2: Configuring the Settings

    After completing the installation process, you need to go to the vsftpd configuration file to make the necessary changes:
    sudo nano /etc/vsftpd.conf

    Below are the key parameters that need to be configured:

     

    Disabling Anonymous Mode:
    anonymous_enable=NO

    This enhances security by allowing access only to registered users.

    Allowing Local Users Access:
    local_enable=YES

    Allows access to local users who have a personal server profile.

    Write Access:
    write_enable=YES


     

     

    Allows interaction with the server by editing and uploading documents.  

    Restart vsftpd after making configuration changes:
    sudo systemctl restart vsftpd


    Step 3: Creating an FTP User

    To correctly perform this procedure, you need to enter:
    sudo adduser ftpuser


     

    Grant permission to work with the necessary directories.

     

    Step 4: Gaining Access to Ports

    For the FTP server to function correctly, it may require the use of ports 20 and 21. To ensure their availability, it is necessary to create the corresponding rule in the firewall:

    sudo ufw allow 20:21/tcp

    sudo ufw reload


     

    Using FTP Clients

     

    Using FTP clients allows for comfortable work with documents via FTP. Below are several widely used clients with various interface designs and functional sets.

    FileZilla

    FileZilla is a free client that supports not only FTP connections but also SFTP/FTPS. FileZilla has open-source code, allowing the client to be used on a variety of platforms including Windows, macOS, and Linux.

    1. Installation: First, you need to download the client, which can be found on  the official website.

    2. Setting Up the Connection: Open FileZilla and fill in all the necessary details (login, password, and server IP address) to establish a connection.

    3. File Transfer: Use the "drag and drop" option to send and receive files.

    Cyberduck

    Cyberduck is an FTP client available for macOS and Windows operating systems. It is compatible with protocols such as FTP, SFTP, and WebDAV, as well as other varieties. It is distinguished by its simple interface and ability to work with cloud storage.

    1. Installing Cyberduck: Download the program from  the official website.

    2. Connecting to the Server: Select the protocol, enter the IP, username, and password to connect.

    WinSCP

    WinSCP is a free FTP and SFTP client for Windows. It integrates with Windows and allows for running remote scripts and synchronizing folders.

    1. Installing WinSCP: Download it from  the official website.

    2. Setting Up the Connection: Open WinSCP, select the connection type (FTP or SFTP), and specify the connection details.

     

    Working with FTP via Command Line

     

    Working with FTP via the command line is an effective way to upload and download files, especially when there is no access to a graphical interface or when it is necessary to automate tasks. This method allows the use of built-in FTP commands to perform operations such as file transfer, directory navigation, and connection setup.

     

    Connecting to an FTP Server via Console

     

    To start working, enter the command ftp in the command line, specifying the address of the FTP server.

    To connect to the FTP server, enter:
    ftp yourserver.com


     

    After entering the command, you will be prompted to enter your username and password.

    Main FTP Commands for the Console

    Using commands that allow working with various directories and documents will be possible after a successful connection.

    Main Navigation Commands

    ls — displays a list of directories and documents in the current server directory.

     

    • cd <directory_name> — allows you to change the current server directory.
      cd uploads

    • pwd — displays the current server directory.
      pwd

     

    File Transfer

    Using the put and get commands allows you to transfer files between the server and the local PC, uploading and downloading them.

    • put <file_name> — uploads a file from the local computer to the server in the current directory.
      put localfile.txt

    • mput <file_pattern> — uploads multiple files matching the pattern.
      mput *.txt

    • get <file_name> — downloads a specific file from the server to the local PC.
      get remotefile.txt

    • mget <file_pattern> — downloads multiple files matching the pattern.
      mget *.log

     

    Administering the Server File System

    • mkdir <directory_name> — allows you to create a new directory on the server.
      mkdir newfolder

    • rmdir <directory_name> — removes an empty server directory.
      rmdir oldfolder

    • delete <file_name> — deletes a specific document on the server.
      delete oldfile.txt

     

    Additional Commands for Session Management

    • ascii and binary — set the data transfer mode.

      • ascii — used for text files.

      • binary — used for binary files (images, archives) to avoid errors.
        binary

    • bye or quit — ends the FTP session.
      bye

     

    Automated File Upload Script

    To automatically download or upload files, you can develop a script that will regularly connect to the FTP server and perform the necessary operations. Here is an example of a bash script for automated file uploads:

    • #!/bin/bash

    • HOST='yourserver.com'

    • USER='ftpuser'

    • PASS='password'

    • ftp -inv $HOST <<EOF

    • user $USER $PASS

    • cd uploads

    • put localfile.txt

    • bye

    • EOF

    In this script:

    • ftp -inv $HOST starts the FTP session in non-interactive mode.

    • user $USER $PASS logs in.

    • cd uploads changes to the desired directory.

    • put localfile.txt uploads the file.

     

     

    Recommendations for Using FTP via Console

     

    1. Use binary mode for uploading binary files to avoid corruption.

    2. Check the connection before starting the transfer, as interruptions can cause errors.

    3. For data protection, it is recommended to use SFTP or FTPS.

     

     

    Conclusion

     

    FTP is a powerful tool for managing files on a server, especially when combined with clients such as FileZilla and Cyberduck. However, for transferring sensitive data, it is recommended to use secure versions of the protocol, such as SFTP.