Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Last active March 28, 2024 14:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joshschmelzle/6aa786e5da37eea77b4bf0fcf85c3881 to your computer and use it in GitHub Desktop.
Save joshschmelzle/6aa786e5da37eea77b4bf0fcf85c3881 to your computer and use it in GitHub Desktop.
running tftp server on ubuntu

Using tftpd-hpa - HPA's tftp server on Ubuntu 18.04.3 LTS to host a tftp server.

install tftp server

$ sudo apt install tftpd-hpa

configure tftp server

create new directory for tftp.

$ sudo mkdir /data
$ sudo mkdir /data/tftp

edit permissions.

$ sudo chmod -R 777 /data/tftp
$ sudo chown -R nobody /data/tftp

modify config to use new directory.

default:

$ cat /etc/default/tftpd-hpa 
# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure -v"

use an editor to change the tftp_directory value.

new:

$ cat /etc/default/tftpd-hpa 
# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/data/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure -v"

do you want to allow tftp clients to upload files? you'll have to add -c option to tftp_options in the config.

it would look like this: TFTP_OPTIONS="--secure -v -c"

when you are done making changed, restart the tftpd-hpa service with $ service tftpd-hpa restart

test

create a file in /data/tftp and try to download it.

if you enabled --create in the config, try to upload it and then verify it on the server.

hardening

only run a tftp server when you need it to be running.

check if tftp is running with $ netstat -anu | grep ":69 "

install ufw with $ sudo apt install ufw

enable ufw with $ sudo ufw enable

allow tftp when you need it $ sudo ufw allow tftp

disable tftp when you're done $ sudo ufw deny tftp

show status and rules with $ sudo ufw status numbered

misc commands

localhost test

cd /tmp
tftp localhost
get <TESTFILE>

troubleshooting

  • cat /var/log/syslog
  • journalctl -xe
  • systemctl status tftpd-hpa.service

research

  • get search apt for tftp with $ apt-cache search tftp
  • get ubuntu version with $ lsb_release -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment