step 1:首先需要安装tftp-hpa,tftpd-hpa,前者是客户端,后者是服务程序,在终端下输入 sudo apt-get install tftp-hpa tftpd-hpa,安装tftp-hpa和tftpd-hpa。然后还需要安装xinetd,在终端下输入 sudo apt-get install xinetd,安装好xinetd。
step 2: 进入根目录下的etc文件夹(cd /etc/),首先看目录中有没有一个xinetd.conf文件,如果没有则新建一个,有的话查看内容,看是否与下面的一致,若不一致则修改,内容如下:
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
}
includedir /etc/xinetd.d
step 3:配置tftp服务器
命令:sudo vim /etc/default/tftpd-hpa
将内容修改成
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -s"
step 4:然后进入xinetd.d文件夹(cd /etc/xinetd.d),查看是否有一个tftp文件,如果没有就新建一个,如果有的话就查看内容是否与下面的一致,不一致则修改,内容如下:
service tftp
{
socket_type=dgram
wait=yes
disable=no
user=root
protocol=udp
server=/usr/sbin/in.tftpd
server_args=-s/tftp
per_source=11
cps=100 2
flags=IPv4
}
<pre name="code" class="html">step 5: 修改所需文件夹的权限。需要修改的文件夹也就是上一步提到的那个服务器文件存放的文件夹,以我的配置文件为例,创建一个文件夹(sudo mkdir /tftp),然后把它可以设置成访问权限最宽松的(sudo chmod 777 /tftp),也可以设置成合适的权限。
step 6: restart the service.
sudo service tftpd-hpa restart
sudo /etc/init.d/xinetd reload
sudo /etc/init.d/xinetd restart
step 7: verify the setup of tftp.
1, make a new file in the /tftp folder, name is a.txt. command is "touch a.txt".
2, switch into another folder, use command "tftp" to start the tftp service. and use command "get a.txt" to download the file, if there is no information returned, it is successful.
then you can find a file named a.txt in the current folder. You also can use command "put name.format" to upload file to the "tftp" folder.
use command "q" to terminate the service.