Loading...

Lab 67: FTP - File Transfer Protocol

Perform basic file transfer operations against an FTP server: connect, authenticate, list remote files, download artifacts, upload a report, and exit cleanly. Use this workflow to move data in legacy environments while documenting what was transferred.

networking access core

Scenario

You need to upload and download files from an FTP server to support a legacy transfer workflow. You will connect to an FTP server, authenticate using anonymous login, list available files, download readme.txt, upload a local report.log, and then close the session cleanly.

Operator context

FTP is legacy and typically unencrypted. In production, prefer SFTP/SSH or HTTPS-based transfers when possible. When FTP is unavoidable, validate each transfer and leave an audit trail.

Objective

  • Connect to an FTP server from the terminal.
  • Authenticate using anonymous login.
  • List remote files and confirm availability.
  • Download a file and upload a file.
  • Exit the FTP client cleanly.

Concepts

  • FTP control channel versus data channel behavior during transfers.
  • Why FTP is considered insecure (credentials and data can be sent in cleartext).
  • Anonymous FTP authentication and common policy constraints.
  • Verifying intent before action: list remote contents prior to transfer.
  • Transfer validation: confirm completion messages and verify local/remote results.
  • Session hygiene: terminate cleanly to avoid hanging sessions and stale state.

Walkthrough

Step 1 : Connect to the FTP server.
Command
ftp ftp.lpic-server.org

This starts an interactive FTP client session and prompts for a username.

Connected to ftp.lpic-server.org.
220 (vsFTPd 3.0.3)
Name (ftp.lpic-server.org:lab):
Step 2 : Log in using anonymous authentication.
Input
anonymous

Anonymous FTP commonly accepts any password depending on server policy. The operational goal is a successful login and a usable transfer mode.

331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
Step 3 : List files on the server.
Command
ls

Validate what is available before transferring. This also confirms you are operating in the expected remote directory.

-rw-r--r--   1 ftp  ftp        1048576 Jan 01 12:00 backup.tar.gz
-rw-r--r--   1 ftp  ftp          20480 Jan 01 12:01 readme.txt
Step 4 : Download readme.txt to the local machine.
Command
get readme.txt

This pulls the remote file into the current local working directory. Confirm the transfer completes successfully.

local: readme.txt remote: readme.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection.
226 Transfer complete.
Step 5 : Upload a local file named report.log.
Command
put report.log

This pushes the local file to the remote server using the same filename unless otherwise specified.

local: report.log remote: report.log
200 PORT command successful.
150 Opening BINARY mode data connection.
226 Transfer complete.
Step 6 : Close the FTP session cleanly.
Command
bye

Exiting cleanly closes the control connection and prevents hanging sessions on the server.

221 Goodbye.

Common breakpoints

Connection fails before login prompt

Confirm DNS resolution and reachability to TCP/21. If the environment blocks FTP, pivot to SFTP/SSH or an approved transfer method.

Anonymous login rejected

Not all servers allow anonymous access. Use the correct account credentials or request access through the proper channel.

Transfers fail with passive/active mode issues

NAT and firewalls commonly interfere with FTP data connections. If you see repeated data connection failures, switch transfer mode per policy or use a modern protocol.

File transferred but content is not correct

Confirm you are in the expected remote directory and that you pulled the correct filename. Validate checksums when integrity matters.

Cleanup checklist

This lab is operationally stateful only in terms of files you transferred. Cleanup is verifying what landed locally and what was uploaded remotely, then exiting the client.

Commands
ls -l readme.txt report.log
# If still connected:
# bye
Success signal

You can show a completed download and upload with clear file names, and the FTP session is closed cleanly.

Reference

  • ftp <host> : Starts an interactive FTP client session to the specified server.
  • ls : Lists remote directory contents within the FTP session.
  • get <remote_file> : Downloads a file from the FTP server to the local machine.
  • put <local_file> : Uploads a local file to the FTP server.
  • bye : Terminates the FTP session and closes the connection.
    • quit is an equivalent command in many FTP clients.