tftp错误代码2访问冲突(tftp不工作)

系统信息:

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 

使用Ubuntu 14.04.2 LTS。

我正在努力运行tftp localhost。

尝试:

 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 

现在我收到错误:

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

我试图提供的文件的权限是:

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

/ tftpboot文件夹的权限:

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

附加信息

 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 } 

请帮我解决这个问题。

要通过tftp放置的文件必须存在于目标目录中,并具有允许覆盖的权限。 对于您的实例, test必须存在于/tftpboot

你可以在tftp手册页BUGS部分看到原因。

我正在努力解决如何通过tftp放置一个新文件,但仍然不知道如何。

检查syslog ,你会看到:

  tftpd: serving file from /srv/tftp 

基本上有一个错误,你需要在你的情况下将所有文件从文件夹/tftpboot/srv/tftp (如果不存在则使文件夹/srv/tftp )并确保你给予所有777权限文件里面,重启xinetd ,它会工作!

这可能是因为14.04在/etc/inetd.conf有一个tftp服务器设置:

 #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 

你可以注释掉这一行,然后再试一次。

我从这里得到了这个: http : //www.beer.org/blog/tftpd-and-xinetd-on-ubuntu.html

作为leondgarse提及,您无法直接使用您的设置上传新文件。 但是你可以在server_args中添加“-c”,例如:

 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 } 

有关详细信息,您可以看到“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. 

不确定这是否与TFTP的设计有关,但在执行put时它不允许您创建文件。

解:

事先创建文件并授予777权限。 再次运行转移它应该工作。

请检查文件模式位。

就我而言,tftp根目录是/opt/tftpboot/

使用ls -l命令,我可以看到文件模式是600,所以当我尝试访问tftp以匿名获取此文件时,它会报告访问冲突。

这可能是导致此错误的原因。 但可能还有另一个原因。