Raspberry Pi – TFTP Server

Raspian – 2013-02-09-wheezy-raspbian
TFTPD Version – tftpd-hpa_5.2-4_armhf.deb

After running into a change in how UFW worked on a previous post versus how someone who tried to do it after watching my video, I decided to start post the version of Raspian and the version of the app I am working with just as a point of reference for the article. In this post, I am going to setup tftpd-hpa. Anyone who has worked with network gear knows how handy it will be to have a tftp server handy without having to install the service on a server or tie up a laptop when it may not be possible to do so.
[youtube]http://youtu.be/9Lp9u9ooKgg[/youtube]
You start the install proces by using sudo apt-get install tftpd-hpa. After the tftpd has installed it will fail to start. After spending several hours of searching for the answer I found an answer that made sense. Apparently, tftpd-hpa was written to look for ipv6 and wont start if it doesnt see it running. If you look at /var/log/syslog, you will see a “bad descriptor” error message. This doesnt really tell you where the problem is. The way around this is to hard code the config file to only look for ipv4.

Edit the file by using sudo nano /etc/default/tftpd-hpa

Here is a sample config of what you should see when opening the file –

TFTP_USERNAME=”tftp”
TFTP_DIRECTORY=”/srv/tftp”
TFTP_ADDRESS=”0.0.0.0:69″
TFTP_OPTIONS=”–secure”

Add -4 or –ipv4 between the quotes on the TFTP_OPTIONS line in the file. After you save the change and exit nano. You will need to restart tftpd-hpa by doing sudo service tftpd-hpa restart. Doing a sudo service –status-all and you will see that tftpd-hpa is now showing as started.

According to what the man page says, by adding –create on the same TFTP_OPTIONS line, you should be able to upload a file without it already existing. As you can see by the video, that didnt work for me. Will have to do some digging on this to find out what the problem is. As you can see from the video (which has been updated) you can now upload a file that didnt previously exist on the RPi without doing a touch command to create a null file before uploading to the tftpd-hpa service on the RPi. This gets you a tftp server very much like what I have used on Windows in the past.

You will also need to do a sudo chmod -R 777 /srv/tftp (-R says to run this command at the directory and below, recursively). This should make the tftp server to where you can upload files without having to do a touch and create a null file first. I tried lesser versions of permissions and found that 777 was the only one that worked.

Tftp is not secure and I wouldnt leave it up and running except when absolutely necessary. If you have to leave it up for prolonged periods of time, it would be good to use UFW to restrict the devices that are able to talk to it. For some legacy devices, using tftpd-hpa may be one of the few options available for transferring files and/or configs from a device.

To see more of my posts about the Raspberry Pi, please go to http://www.ronnutter.com/category/raspberry-pi/

Send to Kindle
This entry was posted in Blog Entries, Raspberry Pi and tagged . Bookmark the permalink.