ubuntu9.10 tftpd-hpa 服务器配置

1、安装tftp的server和client,还有xinetd      注意:需要先安装xinetd,否则下面安装tftpd-hpa和tftp-hpa或报错。
代码:
sudo apt-get install xinetd tftpd-hpa tftp-hpa

 

说明:tftpd-hpa 是服务器,tftp-hpa是客户端


2、xinetd会建立目录/etc/xinetd.d/,在这个目录下建立新文件 tftpd
代码:
sudo touch tftpd


3、编辑 sudo gedit /etc/xinetd.d/tftpd,加入以下内容        注意:这个既可以使tftp,也可以是tftpd,都可以get到file,put  file则出错。 不知为什么?难道是客户与服务端有关系,这个不懂?????
代码:
service tftp
      {
                 disable = no
                 socket_type = dgram
                 wait = no
                 user = root
                 protocol = udp
                 server = /usr/sbin/in.tftpd
                 server_args = -s -l -c /tftpboot                 这两个参数可以加也可以不加,看具体情况而定
                 log_on_success = PID HOST DURATION
                 log_on_failure = HOST
       }

注意:/tftpboot 是你的tftp的根目录,其它的不用修改

说明:我安装的ubuntu9.10在这个目录下是没有tftpd这个文件的,需要自己新建一个。

4、建立tftp根目录
代码:
sudo mkdir /tftpboot

修改权限
代码:
sudo chmod 777 /tftpboot    注意:没有这个,可能会出现Error code 0: Permission denied


5、修改/etc/inetd.conf文件
代码:
sudo gedit /etc/inetd.conf

修改下面这行
代码:
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot


代码:
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /tftpboot

6、修改/etc/default/tftpd-hpa
代码:
sudo gedit /etc/default/tftpd-hpa

内容修改如下
代码:
#Defaults for tftpd-hpa
      RUN_DAEMON="yes"
      OPTIONS="-l -s /tftpboot"


7、重启服务
代码:
sudo /etc/init.d/xinetd restart
      sudo /etc/init.d/tftpd-hpa restart


8、不要忘记修改/home/tftpd 下文件的权限
代码:
chmod 777 *

说明:这个也不一定要777这么大权限,视具体权限而定。

9.测试:

cd /        //进入用户目录或其他目录

tftp 192.168.34.40    //本机ip  或者  tftp localhost
>get  1     //1 tftpboot目录里的文件,从tftp 服务器获取文件1,获取后,会自动放在当前目录下。


这样设置好后,只能get文件,但是不能put文件,不知道为什么?继续探索中。。。。

 

http://blog.csdn.net/wfing/archive/2010/07/12/5729091.aspx

 

可是上传文件不成功,

提示错误:

tftp> put dic.txt
Error code 2: Access violation

求助于google, 得下面一段说明,问题解决。

The tftp man page says:

Because there is no user-login or validation within the TFTP
protocol, the remote site will probably have some sort of
file-access restrictions in place. The exact methods are
specific to each site and therefore dif ficult to document here.

So apparently the site you're trying to get the file from has some
kind of access restrictions in place. Take a look at the tftpd man
page on the remote host. The linux tftpd manual says, in part, "Due to
the lack of authentication information, tftpd will allow only publicly
readable files to be accessed. Files may be written only if they
already exist and are publicly writable."

上面主要意思就是: tftp服务器缺少必要的身份验证,

所以默认只允许下载文件,要上传文件,必须是服务器中已存在同名的文件,

且该文件权限允许被覆盖。


所以首先在服务中创建一个与要上传的文件同名的文件,并更改权限。

$ touch test

$ chmod 777 test

重新上传,成功。
tftp> put test

 

测试成功。

 

如果出现无法get或者put的时候,可以查看一下防火墙是否关闭。

 


创建同名文件,并改变它的权限777,然后客户端用一个同名文件去覆盖它既可。


ubuntu10.04下   http://blog.chinaunix.net/space.php?uid=25695950&do=blog&id=2377750

#/etc/default/tftpd-hpa

 

    TFTP_USERNAME="tftp"

    TFTP_DIRECTORY="/tftpboot"                         

    修改以下TFTP_DIRECTORY就行了,其他同上.




 sudoservice tftpd-hpa restart

     sudo/etc/init.d/xinetd reload

     sudo/etc/init.d/xinetd restart

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值