网上的东西不一定正确,要自己实践。我按照以下步骤做配置成功了。
一、ftp安装
$ sudo apt-get install tftp tftpd xinetd (分别是客户端、服务端、超级进程守护程序)
二、ftp配置
$ cd /
$ sudo mkdir tftpboot
$ sudo chmod 777 tftp boot
2.2 在 /etc/xinetd.d/目录下建立tftp配置文件
$ sudo vim /etc/xinetd.d/tftp
输入:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot 替换为你的目录,注意权限。
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
2.3 将/etc/inetd.conf中关于tftp的部份注释掉:
即是在
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftp
前面加个#:
#tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftp
(若此文件不存在,则直接新建后里面加入/tftpboot,保存退出即可)
2.4 重新启动服务
sudo /etc/init.d/xinetd restart 若出现:
* Stopping internet superserver xinetd [ OK ]
* Starting internet superserver xinetd [ OK ]
表明安装成功了。
接下来进行测试
2.5 在tftpboot文件夹下新建测试文件tftptest
cd /tftpboot
sudo touch test
sudo chmod 777 test
2.6 开始测试 tftp服务
$ cd ~ //回到自己有读写权利的文件夹
#tftp 192.168.1.101 //你自己的IP地址 (切换成系统管理员)
tftp>get test
若出现:Received 6 bytes in 0.0 seconds
则说明tftp安装成功!
注意:
1:如果出现 permission denied 错误 则是操作者权限不够, 需要提升权限 su root 输入密码后就可以正常进行 tftp传输操作了 。
2:如果出现 Access violation错误 则是文件权限没有解开, 将要操作的文件操作权限全解开就可以了 chmod 777 文件名
3:Transfer timed out.
(1)若是在测试出现这个问题,最可能的是 xinetd 更新不成功,
(2)可能是tftp错了,
4:Error code 1: File not found
(1)被传输文件的权限问题
(2)路径问题,或者说使用不正确