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 backup data in legacy environments while documenting what was transferred.

network remote-access core

Scenario

You need to upload and download files from an FTP server to support a legacy backup 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 properly.

Operator context

FTP is legacy and typically unencrypted. In production, prefer SFTP/SSH or HTTPS-based transfers when possible. When FTP is unavoidable, focus on precise commands, clear validation of transfers, and leaving an audit trail.

Objective

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

What You’ll Practice

  • Starting an interactive FTP session with ftp <host>.
  • Performing anonymous login and navigating FTP prompts.
  • Using ls to list remote directory contents.
  • Transferring files using get and put.
  • Closing sessions safely with bye or quit.

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 (often an email address) depending on server policy. The key outcome is a successful login and transfer mode selection.

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 helps confirm you are 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

Properly exiting ensures the control connection is closed and prevents hanging sessions on the server.

221 Goodbye.

Reference

  • ftp <host> : Starts an interactive FTP client session to the specified server.
  • anonymous : Common username for anonymous FTP access when enabled by the 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 / quit : Terminates the FTP session and closes the connection.