tftpd-hpa使用完全教程

来源:互联网 发布:sql password函数 编辑:程序博客网 时间:2024/06/08 15:19

0,源代码下载地址:https://www.kernel.org/pub/software/network/tftp/

1,安装,

sudo apt-get install tftpd-hpa
2,tftp-hpa 的配置文件为 /etc/default/tftpd-hpa

#Defaults for tftpd-hpa
RUN_DAEMON="no"
OPTIONS="-s /home/ch/tftpboot -c -p -U 077 -u tftpd"
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/home/ch/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"


3,使用选项,-s选项,secure选项,后面要跟一个目录,否则会报错。

Dec 13 14:14:42 ch-Founder-PC in.tftpd[12796]: no -s directory

-c选项,是可以写文件。但是-c选项必须要在-s选项存在的情况下才能发挥作用。

-l选项,可以自己启动,不依赖与xinetd,或者/etc/init.d/tftpd-hpa脚本。

-v选项会在/var/log/syslog里面写入日志,-vv会写入更详细的信息。

root@ch-Founder-PC:~# /usr/sbin/in.tftpd  -l -vv -s /home/ch/tftpboot




root@ch-Founder-PC:~# tftp 172.22.24.150
tftp> put openbsdinetd
Error code 1: File not found
tftp> put strlcpy.c
Error code 1: File not found                      这里是没有使用-c选项
tftp> put strlcpy.c
Sent 480 bytes in 0.0 seconds                 这里是使用了-c选项
tftp> put strlcpy.c
Error code 2: Only absolute filenames allowed    这里没有使用-s选项
tftp> put /root/strlcpy.c
Error code 0: Permission denied                           这里使用了-c选项,但是没有使用-s选项
tftp> put strlcpy.c
Sent 480 bytes in 0.0 seconds                                这里使用了-s选项和-c选项
tftp>



root@ch-Founder-PC:~# /usr/sbin/in.tftpd  -l -vv -s /home/ch/tftpboot -c
root@ch-Founder-PC:~# /usr/sbin/in.tftpd  -l -vv  -c
root@ch-Founder-PC:~# /usr/sbin/in.tftpd  -l -vv -s /home/ch/tftpboot -c


Dec 13 14:35:53 ch-Founder-PC in.tftpd[12944]: WRQ from 172.22.24.150 filename openbsdinetd
Dec 13 14:35:53 ch-Founder-PC in.tftpd[12944]: sending NAK (1, File not found) to 172.22.24.150
Dec 13 14:36:24 ch-Founder-PC in.tftpd[12945]: WRQ from 172.22.24.150 filename strlcpy.c
Dec 13 14:36:24 ch-Founder-PC in.tftpd[12945]: sending NAK (1, File not found) to 172.22.24.150
Dec 13 14:38:59 ch-Founder-PC in.tftpd[12965]: WRQ from 172.22.24.150 filename strlcpy.c
Dec 13 14:40:58 ch-Founder-PC in.tftpd[12977]: WRQ from 172.22.24.150 filename strlcpy.c
Dec 13 14:40:58 ch-Founder-PC in.tftpd[12977]: sending NAK (2, Only absolute filenames allowed) to 172.22.24.150
Dec 13 14:42:17 ch-Founder-PC in.tftpd[12982]: WRQ from 172.22.24.150 filename /root/strlcpy.c
Dec 13 14:42:17 ch-Founder-PC in.tftpd[12982]: sending NAK (0, Permission denied) to 172.22.24.150
Dec 13 14:43:39 ch-Founder-PC in.tftpd[12995]: WRQ from 172.22.24.150 filename /root/strlcpy.c
Dec 13 14:43:39 ch-Founder-PC in.tftpd[12995]: sending NAK (0, Permission denied) to 172.22.24.150
Dec 13 14:50:13 ch-Founder-PC in.tftpd[13032]: WRQ from 172.22.24.150 filename strlcpy.c



    length = strlen(msg) + 1;
    memcpy(tp->th_msg, msg, length);
    length += 4;                /* Add space for header */