How to Set Up a TFTP Server on Ubuntu Server with tftpd-hpa

Install Ubuntu’s tftpd-hpa server and tftp-hpa client. This setup serves files from /srv/tftp and keeps uploads in a separate directory. Check the Ubuntu server package and client package listings.

Security: TFTP has no login or encryption. Restrict access to a trusted LAN; reachable clients can read available files and may upload where permissions allow. Do not transfer secrets. The TFTP specification describes its security limits.

Set up the TFTP server

1. Install the server and client

Refresh APT metadata, then install both packages:

sudo apt update
sudo apt install tftpd-hpa tftp-hpa
Ubuntu Server terminal showing the command to install tftpd-hpa and tftp-hpa
Install the server and client packages.

2. Configure the TFTP root

Edit the package configuration file:

sudo nano /etc/default/tftpd-hpa

Set these values:

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure --create --umask 027"

--secure confines the daemon to its configured root, --create allows uploads, and --umask 027 limits new upload files to mode 0640. The Ubuntu tftpd manual documents these options. Save with Ctrl+O, press Enter, then Ctrl+X.

Because --secure makes /srv/tftp the client-visible root, filenames are relative to it: use hello.txt, not /srv/tftp/hello.txt. TFTP clients do not browse directories, so keep a list of published filenames and their paths.

Terminal editor showing tftpd-hpa configured with the /srv/tftp root, secure mode, uploads, and umask 027
Confine files and set the upload mask.

3. Create the root and upload directory

Keep the main root owned by root, and give write access only to the upload folder:

sudo install -d -o root -g root -m 0755 /srv/tftp
sudo install -d -o tftp -g tftp -m 0750 /srv/tftp/upload

The daemon can read the root but only the tftp account can write in /srv/tftp/upload. Avoid making the whole tree world-writable with permissions such as 777.

Files in the public root should be treated as readable by every allowed client. Keep that tree limited to boot images, firmware, or other material intended for that network. For private transfers, choose a protocol with authentication and encryption.

Ubuntu terminal creating /srv/tftp/upload with the tftp user and group and mode 0750
Only the upload subdirectory is writable.

4. Add a file to serve

Create a known file in the root. TFTP’s default read checks require served files to be publicly readable, so set mode 0644:

echo 'TFTP test file' | sudo tee /srv/tftp/hello.txt
sudo chmod 0644 /srv/tftp/hello.txt
Ubuntu Server terminal writing hello.txt into /srv/tftp and setting file permissions to 0644
Create a known file for the download test.

5. Enable and restart the service

Enable the unit at boot, restart it to apply the settings, and inspect its status:

sudo systemctl enable tftpd-hpa
sudo systemctl restart tftpd-hpa
sudo systemctl status tftpd-hpa --no-pager

If startup fails, check the service log with sudo journalctl -u tftpd-hpa -b --no-pager.

Ubuntu Server terminal commands to enable, restart, and inspect the tftpd-hpa service
Restart the service after changing its settings.

6. Limit firewall access

If UFW is enabled, allow the initial request only from your client subnet. Replace the example network with your trusted LAN range:

sudo ufw allow from 192.168.1.0/24 to any port 69 proto udp
sudo ufw status

See Ubuntu’s UFW guide for source-network rules. TFTP starts on UDP port 69, then uses a server-selected UDP port for file data, as described in the protocol specification. A strict firewall, router, or NAT device may allow the request but block the transfer. If clients time out, use TFTP-aware connection tracking or an appropriate firewall policy; do not open every UDP port or expose TFTP to the internet. This command adds a rule; it does not enable UFW. If you administer the server over SSH and intend to turn on an inactive firewall, allow SSH first to preserve remote access.

UFW command allowing UDP port 69 only from the example 192.168.1.0/24 subnet
Allow initial requests from a trusted subnet.

Test downloads and uploads

7. Download from an Ubuntu client

On the server, run ip -brief address and note its reachable LAN address. On an Ubuntu client, install the client if needed. Replace 192.0.2.10 below with the real server address:

sudo apt install tftp-hpa
tftp 192.0.2.10
tftp> binary
tftp> get hello.txt
tftp> quit

The file is saved in the client’s current directory. The Ubuntu tftp client manual documents binary and get. Binary mode is recommended for firmware, boot images, and files whose bytes must remain unchanged. Linux filenames are case-sensitive, so enter each remote name exactly.

TFTP client terminal connecting to the example server and downloading hello.txt in binary mode
Request the known file in binary mode.

8. Upload into the restricted folder

On the client, create a test file, then send it to a path under the server’s upload directory:

printf 'Upload test' > upload-check.txt
tftp 192.0.2.10
tftp> binary
tftp> put upload-check.txt upload/upload-check.txt
tftp> quit

Use the server’s actual address. The remote path is relative to /srv/tftp; verify the upload on the server with sudo ls -l /srv/tftp/upload/. TFTP clients use known filenames rather than browsing a directory listing.

TFTP client terminal sending upload-check.txt to upload/upload-check.txt in binary mode
Uploads stay within the writable subdirectory.

Troubleshoot common errors

  • File not found: Check the filename relative to /srv/tftp and confirm it exists.
  • Access violation: Make served files publicly readable; for uploads, check the tftp ownership of the destination and confirm --create is set.
  • Timeout: Confirm the client uses the server’s reachable address, the service is active, and the firewall permits the negotiated UDP data flow.

To isolate a network issue, test from a client on the same LAN first. If that works but a routed client times out, check the router or firewall for TFTP-aware handling of the negotiated data port.

For a read-only service, remove --create from TFTP_OPTIONS and restart tftpd-hpa.

Leave a Comment

How to Share Files Over Bluetooth on Linux with Blueman

How to Share Files Over Bluetooth on Linux with Blueman

Send and receive files over Bluetooth on Linux with Blueman. Install OBEX support, pair devices, choose a file, accept transfers, and fix common issues.

How to Connect to Servers with GNOME Files

How to Connect to Servers with GNOME Files

Connect GNOME Files to SSH/SFTP, FTP, SMB, WebDAV, or NFS with the correct server URI, sign-in details, and fixes for common connection errors.

How to Connect to Servers in Linux With the KDE Dolphin File Manager

How to Connect to Servers in Linux With the KDE Dolphin File Manager

Open SFTP, SSH, SMB, FTP, NFS, and WebDAV locations in Dolphin, sign in safely, transfer files, and save network folders for later.

How to Use a PS4 Controller on Linux: USB, Bluetooth, and Steam

How to Use a PS4 Controller on Linux: USB, Bluetooth, and Steam

Connect a DualShock 4 to Linux by USB or Bluetooth, then check controller detection and configure Steam Input only when a game needs it.

How to Speed Up the Fedora Linux App Installer

How to Speed Up the Fedora Linux App Installer

Use DNF5 parallel downloads to reduce RPM install waits in GNOME Software, then tell when mirror or Flatpak delays need a different fix.

How to Use iCloud on Linux Through Your Web Browser

How to Use iCloud on Linux Through Your Web Browser

Access iCloud on Linux in a current browser. Learn how to sign in, use iCloud Drive and other web apps, and understand the limits of browser access.

How to Back Up the Linux Bootloader to a USB Drive

How to Back Up the Linux Bootloader to a USB Drive

Save GRUB settings, boot files, and UEFI entry details to removable storage, then use rescue media to repair the correct boot path safely.

How to Install and Set Up Bitwarden on Linux

How to Install and Set Up Bitwarden on Linux

Install Bitwarden on Linux with the right DEB, RPM, Snap, Flatpak, or AppImage package, then sign in and set a secure vault timeout.

How to Change the Screensaver on Xfce: Choose a Theme and Set the Idle Time

How to Change the Screensaver on Xfce: Choose a Theme and Set the Idle Time

Pick a screensaver theme in Xfce, preview it, choose when it starts, and configure automatic locking in the separate Lock Screen tab.

How to Disable the Screensaver in GNOME Shell

How to Disable the Screensaver in GNOME Shell

Stop GNOME Shell from blanking or locking your display automatically. Change Power and Screen Lock settings, or use Caffeine for a temporary keep-awake toggle.