在Ubuntu上建立tftp服务器 ( Set up tftp server on Ubuntu )
来源:互联网 发布:电工画图软件 编辑:程序博客网 时间:2024/05/17 07:17
tftp(Trival File Transfer Protocol)是一种轻量级的文件传输协议,TFTP报文封装在UDP包之中(默认端口:69),并不可靠,因此不能 ls
,也不能认证。
但是,在嵌入式开发中,它能够为目标机提供高速下载服务。由于是在局域网中,因此数据出错的概率也是相当小。
在Ubuntu上安装tftp服务器并不复杂:
安装ftpd以及相关软件包
$ sudo apt-get install xinetd tftpd tftp
创建文件
/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 disable = no }或者service tftp {socket_type = dgramprotocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4} 重点是:server_args = -s /tftpboot和 disable = no两个选项,(注:ubuntu下-c参数不能使用,添加后服务器无响应??why?)
在系统根目录下创建tftproot目录,并修改权限
$ sudo mkdir /tftpboot $ sudo chmod -R 777 /tftpboot $ sudo chown -R nobody /tftpboot
启动tftp服务
$ sudo /etc/init.d/xinetd stop $ sudo /etc/init.d/xinetd start
测试:传输一个文件
本测试将先与本机连接,然后再传送一个已有的文件(例如hello.txt),通过观察文件的修改时间来确定是否传送成功。
$ touch /tftpboot/hello.txt $ chmod 0777 /tftpboot/hello.txt $ ls -l /tftpboot/ total 0 -rwxrwxrwx 1 lesca lesca 0 2011-02-2616:43hello.txt # 连接本地tftp服务器 $ tftp localhost tftp> put hello.txt tftp> quit $ ls -l /tftpboot/ total 8 -rwxrwxrwx 1 lesca lesca 0 2011-02-26 16:48 hello.txt
#时间发生了变化,传送成功
注:localhost如果没有在环境那个变量里面设定 就使用127.0.0.1
The above is from David Sudjiman – Installing and setting TFTPD in Ubuntu Translated and re-shared by Lesca.
附:检查tftpd是否已经启动
$ sudo netstat -lnput Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 929/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1181/cupsd tcp 0 0 0.0.0.0:1723 0.0.0.0:* LISTEN 1110/pptpd tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1172/mysqld tcp6 0 0 :::80 :::* LISTEN 1253/apache2 tcp6 0 0 :::22 :::* LISTEN 929/sshd tcp6 0 0 ::1:631 :::* LISTEN 1181/cupsd tcp6 0 0 :::5500 :::* LISTEN 1825/vinagre udp 0 0 0.0.0.0:52537 0.0.0.0:* 960/avahi-daemon: r udp 0 0 0.0.0.0:68 0.0.0.0:* 1834/dhclient udp 0 0 0.0.0.0:69 0.0.0.0:* 3556/xinetd # It's Here!! udp 0 0 0.0.0.0:5353 0.0.0.0:* 960/avahi-daemon: r
提示:安全性
根据 man 8 tftpd 的描述:
... The use of tftp(1) does not require an account or password on the remote system. Due to thelack of authentication information, tftpd will allow only publicly read‐ able 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....
因此,建议:
1.为tftpd降低UID权限(本文已经将UID设置成nobody)
2.在不使用tftp服务的时候关闭它(disable = yes)
3.为该端口(UDP:69)配置防火墙,阻止外网访问
注意: 1:如果出现permission denied 错误 则是操作者权限不够,
需要提升权限
su root
输入密码后就可以正常进行tftp传输操作了
2:如果出现Access violation错误 则是文件权限没有解开,
将要操作的文件操作权限全解开就可以了
chmod 777 文件名 或者666也可以
- 在Ubuntu上建立tftp服务器 ( Set up tftp server on Ubuntu )
- ubuntu 建立tftp服务器
- Ubuntu 建立tftp服务器
- set up tftp server on redhat system
- Ubuntu下建立tftp服务器
- Ubuntu下建立tftp服务器
- Ubuntu下建立tftp服务器
- Ubuntu下建立tftp服务器
- setup tftp server on ubuntu
- Set up tftp on Fedora
- 在ubuntu上安装tftp服务器与nfs服务器
- ubuntu 10.04 虚拟机建立tftp服务器
- ubuntu 10.04 虚拟机建立tftp服务器
- (转载)Ubuntu下建立tftp服务器
- ubuntu 11.04 上安装 tftp server
- [Ubuntu]: tftp server
- Ubuntu 搭建TFTP Server
- ubuntu安装tftp server
- php的md5
- web开发经验和教训
- 【com】第三者 com基础
- pku1276 Cash Machine(http://poj.org/problem?id=1276)
- JSP元素
- 在Ubuntu上建立tftp服务器 ( Set up tftp server on Ubuntu )
- Jsp验证码
- 深入了解ApusicAS服务器配置系列之——配置虚拟主机
- 请求重定向和转发的区别
- 购物车学习笔记
- jsp指令总结
- 动态切换Struts2的国际化
- 查看浏览次数
- JSP的隐式对象