How to configure tftpd-hpa to change TFTP Server root directory

Post a Comment
After successfully installed and test the TFTP server from the previous article, we are going to configure the TFTP server root directory. So before you continue reading this article, make sure you have read How to Install TFTP Server on Ubuntu 20.04 Server from the previous post and already installed TFTP server successfully.

In this post, we will going to configure the TFTP server to change default root directory. Ubuntu TFTP server, in this case tftpd-hpa default root directory located at /srv/tftp. To change it, we just need edit the configuration file located at /etc/default/tftpd-hpa and change the permission or owner of the new directory.

How to configure tftpd-hpa to change TFTP Server directory?

1. Become root
 sudo su 
then enter your user password.
How to configure tftpd-hpa to change TFTP Server directory
Become root
I always do this, to prevent using sudo on every command after.

2. Edit the configuration file
 nano /etc/default/tftpd-hpa
And change the TFTP_DIRECTORY parameter to your new directory, example:
 TFTP_DIRECTORY="/home/andra/tftp".
Close and save the configuration file by pressing "CTRL+x" followed by "y" and enter.
How to configure tftpd-hpa to change TFTP Server directory
Edit the configuration file

3. Prepare the new directory and change the directory owner
Create new folder if the directory is not exist yet with mkdir, for example:
 mkdir /home/andra/tftp
If you are using the existing directory, just skip the step above and change your folder owner using chown tftp:tftp /FOLDER/PATH, for example:
 chown tftp:tftp /home/andra/tftp
How to configure tftpd-hpa to change TFTP Server root directory
Prepare the new directory and change the directory owner

4. Restart TFTP Server service and make sure it is running and active
 systemctl restart tftpd-hpa
to restart tftpd-hpa service, and then
 systemctl status tftpd-hpa
How to configure tftpd-hpa to change TFTP Server root directory
make sure it is running and active

The service must be active and running, systemctl status tftpd-hpa will also shows you the error if something is wrong.

Related Posts

    Post a Comment

    Subscribe Our Newsletter