ubuntu配置tftp服务的步骤小结

若/etc/xinetd.d/下存在 tftp,执行下列操作

关闭 xinetd服务

  $sudo service xinetdstop  

删除 tftp文件

  $sudo rm /etc/xinetd.d/tftp

启动 xinetd 服务

  $sudo service xinetdstart

安装 tftp 客户端和服务器端

  $sudo apt-getinstall tftp-hpa  $sudo apt-getinstall tftpd-hpa

修改 tftpd-hpa 配置文件

  $vim /etc/default/tftpd-hpa  修改 “/var/lib/tftpboot” 为 “/tftpboot”  修改 "--secure" 为 "--secure -c" 允许上传新文件

若/tftpboot 不存在,创建该目录

  $sudo mkdir /tftpboot  $sudo chmod 777 /tftpboot

重启 tftpd-hpa 服务

  $sudo service tftpd-hpa restart  

若服务重启成功,能查看到相应的进程

  $ps -ef |grepin.tftpd  

测试

在终端执行命令:

  tftp 对方ip地址  下载文件:get 文件名  上传文件:put 文件名  退出:quit

至此 tftp服务已经安装完成了,下面可以对其进行一下测试。(假设在当前目录下有一个测试文件 test.txt)

  $tftp127.0.0.1  tftp> put test.txt  Sent 1018 bytes in 0.0seconds  tftp> get test.txt  Received1018 bytes in 0.1 seconds  tftp> quit  $  

通过 get 命令,可以把当前目录下的 test.txt 文件,通过 tftp 上传到它的服务文件目录。这时,在/tftpboot 下面会出现 test.txt 文件。通过 put 命令,可以从/tftpboot 下,下载 test.txt文件。这样就验证了 tftp 服务配置的正确性。当文件上传与下载结束后,可以通过 quit 命令退出。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

参与评论