通过这个实验,我明白了tftp一些基本的概念问题.
知道如何正确的进行上传和下载.这个实验说明了,root下,在tftpboot下,具有666的文件,才能被覆盖掉.
深刻体会了chmod 的用法.
也明白了读说明书的重要性.反应了我对英文说明书,还是读的能力不够.
Ubuntu 的 openbsd-inetd 預設將 tftpd 的路徑指定為 /srv/tftp,为了不理会srv的权限,所以去修改/etc/inetd.conf文件。
=============================
设置方法:
参考realarm的说明书。
。。。
==================================
ubuntu10。04虚拟机的情况是:
root@ubuntu:/home/zhangbin# uname -a
Linux ubuntu 2.6.32-26-generic #47-Ubuntu SMP Wed Nov 17 15:59:05 UTC 2010 i686 GNU/Linux
==================================
root@ubuntu:/home/zhangbin# apt-get install tftp tftpd 前者是客户端,后者是服务程序。
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
openbsd-inetd 附带有这个软件包安装
The following NEW packages will be installed:
openbsd-inetd tftp tftpd
0 upgraded, 3 newly installed, 0 to remove and 121 not upgraded.
Need to get 71.1kB of archives.
After this operation, 311kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://Ubuntu.cn99.com/ubuntu/ lucid/universe tftp 0.17-17ubuntu1 [17.6kB]
Get:2 http://Ubuntu.cn99.com/ubuntu/ lucid/main openbsd-inetd 0.20080125-4ubuntu2 [37.0kB]
Get:3 http://Ubuntu.cn99.com/ubuntu/ lucid/universe tftpd 0.17-17ubuntu1 [16.5kB]
Fetched 71.1kB in 0s (135kB/s)
Selecting previously deselected package tftp.
(Reading database ... 143343 files and directories currently installed.)
Unpacking tftp (from .../tftp_0.17-17ubuntu1_i386.deb) ...
Selecting previously deselected package openbsd-inetd.
Unpacking openbsd-inetd (from .../openbsd-inetd_0.20080125-4ubuntu2_i386.deb) ...
Selecting previously deselected package tftpd.
Unpacking tftpd (from .../tftpd_0.17-17ubuntu1_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up tftp (0.17-17ubuntu1) ...
Setting up openbsd-inetd (0.20080125-4ubuntu2) ...
* Stopping internet superserver inetd [ OK ]
* Not starting internet superserver: no services enabled
Setting up tftpd (0.17-17ubuntu1) ...
所以一共是安装了三个软件包。
tftd 服务程序
tftp 客户端程序
openbsd-inetd inetd服务器的debian移植版本。
===========================================
关于penbsd的inetd软件包的说明如下:
OpenBSD 互联网超级服务器
inetd 服务器是一个专门管理入网连接的网络后台程序.它的配置文件定义了当收到入 网连接时运行什么程序.任何服务端口都可以用TCP或UDP协议配置.
这是一个有 Debian 专用特色的 OpenBSD 后台移植版.该软件包支持 IPv6,内建的 libwrap 访问控制,绑定到特定地址,UNIX 域套接字和套接字缓冲调解.
=================================================
root@ubuntu:~# vi /etc/inetd.conf
==================================================
文件夹的权限如下:
root@ubuntu:~# ls -l
total 4
drwxrwxrwx 2 root root 4096 2011-02-27 18:37 tftpboot
root@ubuntu:~# ll tftpboot
total 8
drwxrwxrwx 2 root root 4096 2011-02-27 18:37 ./
drwx------ 19 root root 4096 2011-02-27 18:38 ../
据说要改写这个命令。
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot
我并没有使用这个命令,而是重新加载inetd进程:
sudo /etc/init.d/inetd reload
openbsd-inetd是个可执行文件。
root@ubuntu:/etc/init.d# openbsd-inetd restart
openbsd-inetd: command not found
root@ubuntu:/etc/init.d# ./openbsd-inetd restart
* Restarting internet superserver inetd [ OK ]
root@ubuntu:/etc/init.d#
这样是可行的:
root@ubuntu:~/tftpboot# sudo /etc/init.d/openbsd-inetd restart
* Restarting internet superserver inetd [ OK ]
root@ubuntu:~/tftpboot#
=========================
这个命令,不知道做什么的。
root@ubuntu:/etc/init.d# in.tftpd -l /tftpboot
in.tftpd自己也是个命令.
(1)===================================
查询了下帮助手册:
TFTPD(8) BSD System Manager's Manual TFTPD(8)
NAME
tftpd — DARPA Trivial File Transfer Protocol server
tftp 普通文件传送协议(Trivial File Transfer Protocol)
SYNOPSIS
tftpd [-n] [-s] [directory ...]
DESCRIPTION
Tftpd is a server which supports the DARPA Trivial File Transfer Proto‐
col. The TFTP server operates at the port indicated in the ‘tftp’ ser‐
vice description; see services(5). The server is normally started by
inetd(8).
The use of tftp(1) does not require an account or password on the remote
system. Due to the lack of authentication information, tftpd will allow
only publicly readable files to be accessed. Files may be written only
if they already exist and are publicly writable. Note that this extends
the concept of “public” to include all users on all hosts that can be
reached through the network; this may not be appropriate on all systems,
and its implications should be considered before enabling tftp service.
The server should have the user ID with the lowest possible privilege.
Access to files may be controlled by invoking tftpd with a list of direc‐
tories by including pathnames as server program arguments in
/etc/inetd.conf. In this case access is restricted to files whose names
are prefixed by the one of the given directories. If no directories are
supplied the default is /tftpboot. To give out access to the whole
filesystem, should this be desired for some reason, supply / as an argu‐
ment.
Unfortunately, on multi-homed systems, it is impossible for tftpd to
determine the address on which a packet was received. As a result, tftpd
uses two different mechanisms to guess the best source address to use for
replies. If the socket that inetd(8) passed to tftpd is bound to a par‐
ticular address, tftpd uses that address for replies. Otherwise, tftpd
uses ``UDP connect'' to let the kernel choose the reply address based on
the destination of the replies and the routing tables. This means that
most setups will work transparently, while in cases where the reply
address must be fixed, the virtual hosting feature of inetd(8) can be
used to ensure that replies go out from the correct address. These con‐
siderations are important, because most tftp clients will reject reply
packets that appear to come from an unexpected address.
The options are:
-n Suppresses negative acknowledgement of requests for nonexistent
relative filenames.
-s All absolute filenames are treated as if they were preceded by
the first directory argument, or /tftpboot if there is none.
SEE ALSO
tftp(1), inetd(8)
HISTORY
The tftpd command appeared in 4.2BSD.
Linux NetKit (0.17) July 29, 2000 Linux NetKit (0.17)
(2)==========================================
只这样是不行的,因为tftp是要inetd来控制的,而ubuntu或debian类的系统,默认是没有安装inetd的,安装一下:
root@ubuntu:/etc/init.d# apt-get install netkit-inetd
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package netkit-inetd is a virtual package provided by:
inetutils-inetd 2:1.6-3
openbsd-inetd 0.20080125-4ubuntu2
You should explicitly select one to install.
E: Package netkit-inetd has no installation candidate
这个包,ubuntu是通过自己的包来提供的.
(3)=============================================================================
出现了Error code 2: Access violation的错误.
root@ubuntu:~# cd t*
root@ubuntu:~/tftpboot# ls
root@ubuntu:~/tftpboot# touch test
root@ubuntu:~/tftpboot# ls
test
root@ubuntu:~/tftpboot# tftp 127.0.0.1
tftp> get test
Error code 2: Access violation
tftp>
tftpboot是给了 777的权限的.
tftpboot下的test文件,也给了666的权限.
(4)==========================
root@ubuntu:~/tftpboot# netstat -a | grep tftp
udp 0 0 *:tftp *:*
看上去tftp是在运行的.
(5)==============================
原因是,我/tftpboot文件,应是在/下,我把它放在了/root下。
改为/tftpboot就行了。
================================================
【1】tftp的使用,,在任何一个目录下,使用tftp的客户端,访问某个ip的机子上的tftp服务器,访问这个ip的tftpboot目录下的文件。
因此,我在/home/zhangbin下,获取/tftpboot下的hello.txt文件。使用的是get命令。获取成功。
下载文件成功.
root@ubuntu:/home/zhangbin# vi /tftp/hello.txt
root@ubuntu:/home/zhangbin# vi /tftpboot/hello.txt
root@ubuntu:/home/zhangbin# tftp 127.0.0.1
tftp> get hello.txt
Received 34 bytes in 0.0 seconds
tftp> q 退出 tftpd的命令
root@ubuntu:/home/zhangbin# ls
7.wma ear.mpg hello.txt new.txt tftp.txt
code examples.desktop HetNet.wmv oldboy.flv tutorial01
DawnLightPlayer ffmpegjt.c jgs.mp3 oldboy.mp4 tutorial02
Desktop ffmpeg截图.c main.cc out.txt tutorial03
DLP-SVN frame1.ppm manffplay.txt pan.rmvb tutorial08
Documents frame2.ppm man-kill.txt Pictures Videos
dodge.mpg frame3.ppm man-ps.txt Public wavplay
Downloads frame4.ppm man-xargs.txt rjsq.wav whatsInside.wav
ear frame5.ppm Music Templates x264
root@ubuntu:/home/zhangbin# cat hello.txt
hello
hello
hello
hellp
ehll
===============================
【2】上传文件失败,文件权限报错的解决办法(解决办法见 下面的 3))
想吧new.txt上传到tftp服务器中。
Error code 2: Access violation 错误。
///
1)看了下文件权限:
new.txt应该是666的。
-rw-rw-rw- 1 root root 30278 2011-01-30 06:16 new.txt
还是报错:
root@ubuntu:/home/zhangbin# tftp 127.0.0.1
tftp> put new.txt
Error code 2: Access violation
tftp> q
改成666,还是报错
root@ubuntu:/home/zhangbin# chmod 666 new.txt
root@ubuntu:/home/zhangbin# tftp 127.0.0.1
tftp> put new.txt
Error code 2: Access violation
tftp>
============ 重新来 新建立了一个0字节的文件,abc.txt,还是失败. root@ubuntu:/home/zhangbin# vi abc.txt root@ubuntu:/home/zhangbin# cat abc.txt root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put abc.txt Error code 2: Access violation tftp> q 更改权限666,也不行. root@ubuntu:/home/zhangbin# chmod 666 abc.txt root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put abc.txt Error code 2: Access violation tftp> 更改权限777,还是不行. root@ubuntu:/home/zhangbin# chmod 777 abc.txt root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put abc.txt Error code 2: Access violation tftp> q ============================= 2)从tftpboot找问题, 目录d 权限755 drwxr-xr-x 2 root root 4096 2011-02-27 19:11 tftpboot 更改d权限777 root@ubuntu:/# chmod 777 tftpboot 上传new.txt,还是不行. root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put new.txt Error code 2: Access violation tftp> 重启tftpd服务 root@ubuntu:/home/zhangbin# /etc/init.d/openbsd-inetd restart * Restarting internet superserver inetd [ OK ] 不行 root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put new.txt Error code 2: Access violation 说明了不是tftpboot权限,也不是要上传的文件的权限的问题 ========================= 3)参考了文章之后,明白了一点,就是tftp服务器,默认规则是可以下载,但是上传文件的话, 必须在tftpboot中,有一个相同名字的文件,而且具备相应的可读写(覆盖)的权限.这样才能上传文件. 实验一下: 在tftpboot中,创建new.txt,忘记改写权限. 上传失败. root@ubuntu:/home/zhangbin# vi /tftpboot/new.txt root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put new.txt Error code 2: Access violation tftp> q root@ubuntu:/home/zhangbin# ls /tftpboot/ hello.txt new.txt test test.txt 改写了权限之后,上传就成功了. root@ubuntu:/home/zhangbin# chmod 777 /tftpboot/new.txt root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put new.txt Sent 30319 bytes in 0.0 seconds tftp> ======================================== 4)文件必须是644的权限。 root下,新建一个文件,001.txt,打算上传到tftp中. root@ubuntu:/home/zhangbin# vi 001.txt 创建之后的权限是644,就是root可以读写,group和others只能读. root@ubuntu:/home/zhangbin# ls -l total 552872 -rw-r--r-- 1 root root 8 2011-02-27 20:12 001.txt 再在/tftpboot中,创建一个同名的 root@ubuntu:/home/zhangbin# vi /tftpboot/001.txt 权限默认是644,感觉,用root执行上传,可以覆盖. root@ubuntu:/home/zhangbin# ls -l /tftpboot/ total 36 -rw-r--r-- 1 root root 0 2011-02-27 20:14 001.txt 试试 居然不行 root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put 001.txt Error code 2: Access violation tftp> tftpboot下的文件,改成666 root@ubuntu:/home/zhangbin# chmod 666 /tftpboot/001.txt root@ubuntu:/home/zhangbin# ls -l /tftpboot/ total 36 -rw-rw-rw- 1 root root 0 2011-02-27 20:14 001.txt 可以了 root@ubuntu:/home/zhangbin# tftp 127.0.0.1 tftp> put 001.txt Sent 10 bytes in 0.0 seconds tftp>///
原文链接:http://os.51cto.com/art/201001/176508.htm
在向大家详细介绍tftp之前,首先让大家了解下Ubuntu tftp,然后全面介绍Ubuntu tftp,希望对大家有用。Ubuntu 团队对它的使用者公开的承诺:Ubuntu 永远免费 , 并且对于 "企业版本" 没有任何额外的费用, 在同样的自由团队上,将最好的工作成果带给每一个人。
配置Ubuntu tftp服务的步骤:
1、安装相关软件包:Ubuntu tftp(服务端),tftp(客户端),xinetdsudo apt-get install tftpd tftp xinetd
2、建立配置文件在/etc/xinetd.d/下建立一个配置文件tftpsudo vi tftp在文件中输入以下内容:service tftp{socket_type = dgramprotocol = udpwait = yesuser = rootserver = /usr/sbin/in.tftpdserver_args = -s /tftpbootdisable = noper_source = 11cps = 100 2flags = IPv4}保存退出
3、建立Ubuntu tftp服务文件目录(上传文件与下载文件的位置),并且更改其权限sudo mkdir /tftpbootsudo chmod 777 /tftpboot -R
4、重新启动服务sudo /etc/init.d/xinetd restart至此Ubuntu tftp服务已经安装完成了,下面可以对其进行一下测试。(假设在当前目录下有一个测试文件test.txt)$tftp 127.0.0.1 tftp> put test.txtSent 1018 bytes in 0.0 secondstftp> get test.txtReceived 1018 bytes in 0.1 secondstftp> quit
通过get命令,可以把当前目录下的test.txt文件,通过Ubuntu tftp上传到它的服务文件目录。这时,在/tftpboot下面会出现test.txt文件。通过put命令,可以从/tftpboot下,下载 test.txt文件。这样就验证了Ubuntu tftp服务配置的正确性。当文件上传与下载结束后,可以通过quit命令退出。严格按照以上步骤配置Ubuntu tftp服务,一般都可以成功。如果出现无法get或者put的时候,可以查看一下防火墙是否关闭。
如果从tftp服务器下载失败,
要确保服务器的根目录有可执行的权限。
$ chmod -R 777 tftp
使用中发现能正常下载文件,
$ tftp 192.168.1.222tftp> get zImageReceived 1692890 bytes in 0.2 seconds
可是上传文件不成功,
提示错误:
tftp> put dic.txtError code 2: Access violation
求助于google, 得下面一段说明,问题解决。
The tftp man page says:
Because there is no user-login or validation within the TFTPprotocol, the remote site will probably have some sort offile-access restrictions in place. The exact methods arespecific to each site and therefore dif ficult to document here.
So apparently the site you're trying to get the file from has somekind of access restrictions in place. Take a look at the tftpd manpage on the remote host. The linux tftpd manual says, in part, "Due tothe lack of authentication information, tftpd will allow only publiclyreadable files to be accessed. Files may be written only if theyalready exist and are publicly writable."
上面主要意思就是: tftp服务器缺少必要的身份验证,
所以默认只允许下载文件,要上传文件,必须是服务器中已存在同名的文件,
且该文件权限允许被覆盖。
所以首先在服务中创建一个与要上传的文件同名的文件,并更改权限。
$ touch dic.txt
$ chmod 777 dic.txt
重新上传,成功。tftp> put dic.txtSent 13770 bytes in 0.0 seconds
在网上看到有人配/etc/default/tftp,/etc/inetd.conf这些文件,实际上没这么复杂,用tftp和tftpd,加上xinetd监控,只需要配/etc/xinetd./tftp即可。
===========
也有牛人说
http://yuanfarn.blogspot.com/search/label/Linux
在 Ubuntu 上安裝 tftpd 伺服器是一件非常簡單的事,首先執行以下這個指令安裝需要的套件:
sudo apt-get install tftp tftpd openbsd-inetd
然後再執行以下的指令啟動 openbsd-inetd:
sudo /etc/init.d/openbsd-inetd start
基本上,這樣就可以使用 tftpd 了。不過,由於 Ubuntu 的 openbsd-inetd 預設將 tftpd 的路徑指定為 /srv/tftp,我覺得有點不大方便,因此通常習慣再去修改 /etc/inetd.conf,將 /srv/tftp 修改成 /tmp/tftproot,這樣一來,我也不用再去理會 /srv 這個目錄的權限,只要將要藉由 tftp 傳送的檔案直接複製到 /tmp/tftproot 目錄就行了,更方便許多呢!
===============================================================
参考了http://bbs.chinaunix.net/thread-655364-1-1.html
参考了这篇文章
tftp程序,对ubuntu用户来讲,配置这个不是很友好。安装程序代码:sudo apt-get install tftp tftpd前者是客户端,后者是服务程序。只这样是不行的,因为tftp是要inetd来控制的,而ubuntu或debian类的系统,默认是没有安装inetd的,安装一下:代码:sudo apt-get install netkit-inetd在/目录下建一个tftpboot, 把属性改成777。代码:cd /sudo mkdir tftpbootsudo chmod 777 tftpboot修改/etc/inetd.conf代码:tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot重新加载inetd进程代码:sudo /etc/init.d/inetd reload测试一下,在/tftpboot文件夹下新建立一个文件代码:touch aaa进入另外一个文件夹代码:tftp 10.0.0.1tftp> get aaa
=====================================================
http://hi.baidu.com/