5

System info:

Linux ravi-Inspiron-N5010 3.13.0-46-generic #79-Ubuntu SMP Tue Mar 10
20:08:14 UTC 2015 i686 i686 i686 GNU/Linux

Using Ubuntu 14.04.2 LTS.

I am struggling to run tftp localhost.

Tried:

root@ravi-Inspiron-N5010:/home/ravi/Desktop# service tftpd-hpa restart
tftpd-hpa stop/waiting
tftpd-hpa start/running
root@ravi-Inspiron-N5010:/home/ravi/Desktop# service tftpd-hpa status
tftpd-hpa start/running

Now I get error:

root@ravi-Inspiron-N5010:/home/ravi/Desktop# tftp 127.0.0.1
tftp> put test
Error code 2: Access violation
tftp> 

permission of the file I am trying to put is :

root@ravi-Inspiron-N5010:/home/ravi/Desktop# ls -ld test 
-rwxrwxrwx 1 ravi ravi 0 Mar 21 20:09 test

Permission of the /tftpboot folder:

root@ravi-Inspiron-N5010:/# ls -ld  tftpboot/
drwxrwxrwx 2 nobody root 4096 Mar 15 15:34 tftpboot/

Additional Information

root@ravi-Inspiron-N5010:/home/ravi/Desktop# nano /etc/xinetd.d/tftp

service tftp


{
   protocol = udp
   port = 69
   socket_type = dgram
   wait = yes
   user = nobody
   server = /usr/sbin/in.tftpd
   server_args = /tftpboot -s
   disable = no
}

Please help me resolve this issue.

8 Answers 8

5

The file you want to put via tftp must exist in the destination directory, and have permissions allowing it to be overwritten. For your instance, test must exist in /tftpboot.

You can see the reason in the tftp man page BUGS section.

I'm struggling to solve how to put a new file via tftp, but still don't know how.

2
  • Use "-c" argument to support create new file, if you are using tftpd-hpa
    – alfred
    Dec 19, 2017 at 13:55
  • as @alfred mentioned below, not all tftpd implementations supports '-c‘ Jun 14, 2023 at 11:38
4

Check syslog and you will see that :

 tftpd: serving file from /srv/tftp

Basically there is a bug and you will need in your case to move all files from the folder /tftpboot to /srv/tftp (make the folder /srv/tftp if doens't exist) and make sure you give 777 permissions and to all file inside, restart xinetd and it will works!

1
  • Your answer helped me solve this problem. But I solved it by modifying /etc/inetd.conf Jul 21, 2016 at 8:55
2

This could be because 14.04 has a tftp server setting in /etc/inetd.conf:

#BOOT: TFTP service is provided primarily for booting.  Most sites
#       run this only on machines acting as "boot servers."
tftp    dgram  udp wait    nobody  /usr/sbin/tcpd  /usr/sbin/in.tftpd /srv/tftp

you can comment out this line and try again.

I got this from here: http://www.beer.org/blog/tftpd-and-xinetd-on-ubuntu.html

0
2

As leondgarse mention, you cannot upload new files directly with your settings. But you can add "-c" to server_args, like:

service tftp
{
   protocol = udp
   port = 69
   socket_type = dgram
   wait = yes
   user = nobody
   server = /usr/sbin/in.tftpd
   server_args = -c -s /tftpboot
   disable = no
}

For detail, you can see man page of "in.tftpd":

   --create, -c
          Allow new files to be created.  By default, tftpd will only allow upload of files that already exist.  Files are created with default permissions allow‐
          ing anyone to read or write them, unless the --permissive or --umask options are specified.
2
  • Using xinetd I get the "unknown option -?" message in syslog. Is this solution for tftp-hba only?
    – Noel
    Mar 17, 2018 at 13:09
  • 1
    @Noel, yes, not all tftpd implementation supports '-c‘
    – alfred
    Mar 22, 2018 at 15:01
1

In my case it (Debian 9.9) I resolve it by editing /etc/inetd.conf and modifying the line :

tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftp

by

tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot

The file "/etc/xinetd.d/tftp" was not reading.

0

Not sure if this is something with the design of TFTP but when doing a put it does not let you create a file.

Solution:

Create the file before hand and give 777 rights. Run transfer again and it should work.

0

Please check the files mode bits.

In my case, the tftp root directory is /opt/tftpboot/

Using ls -l command, I could see the file mode was 600, so when I try to access tftp to get this file with anonymous, it reports an access violation.

This may be the cause of this error. But there may be another reason for it.

0

Troubleshooting TFTPD Server on Ubuntu 14.0.4 by Dayanand Ambawade

Step-1: Edit /etc/inetd.conf

tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftpboot

Step-2: Write script for tftpd

sudo nano /etc/xinetd.d/tftp

service tftp

{
   protocol = udp
   port = 69
   socket_type = dgram
   wait = yes
   user = nobody
   server = /usr/sbin/in.tftpd
   server_args = /srv/tftpboot -s
   disable = no
}

Step-3: Create Directory and set the permissions

sudo mkdir /srv/tftpboot
sudo echo "Test TFTP Server" > /srv/tftpboot/test.txt
sudo chmod 777 -R /srv/tftpboot
sudo chown -R nobody.root /srv/tftpboot

Step-4: Start service

sudo service xinetd restart
sudo service inetutils-inetd restart

Step-5: Test Server

echo "get test.txt" | tftp 127.0.0.1
cat test.txt
Test TFTP Server

Hopefully this will solve the problem. Regards

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .