您的位置:首页 > 编程语言 > PHP开发

ubuntu下tftp安装和配置

2013-08-23 11:01 543 查看
安装 上传 和 下载 ,可以在 软件中心 安装。搜索tftp-hpa tftpd-hpa
安装 openbsd
sudo apt-get install tftp-hpasudo apt-get install tftpd-hpa
sudo apt-get install openbsd-inetdsudo apt-get install xinetd

去建立一个根目录,然后设置对应的访问属性:1. mkdir /tftpboot2. cd /3. chmod 777 tftpboot/
(a) 在 根目录 下 建立 tftpboot 这个文件夹存放 可以通过ftp协议 传输的文件。注意 该文件夹 及 文件的权限。 (b) chmod 777 就是更改该目录权限

更改配置文件/etc/default/tftpd-hpa
sudo vim /etc/default/tftpd-hpa

去修改配置文件,修改好后,内容如下:1. # /etc/default/tftpd-hpa

2. RUN_DAEMON="yes"
3. OPTIONS="-l -s -c /tftpboot"如果是10.04之前的版本 把下面四行注释掉,如果是 10.04以后的含10.04 把上面两行注释掉
4. TFTP_USERNAME="用户名"5. TFTP_DIRECTORY="/tftpboot"6. TFTP_ADDRESS="0.0.0.0:69"7. TFTP_OPTIONS="-l -s -c"绿色部分是要修改的, OPTIONS="-l -s -c /tftpboot" 绿色部分是 tftpboot 路径, TFTP_USERNAME="用户名" 绿色部分是用户名 TFTP_DIRECTORY="/tftpboot"绿色部分是 路径
OPTIONS="-l -s -c
中的参数含义为:
-l Run the server in standalone (listen) mode, rather than run from inetd. Inlisten mode, the -t option is ignored, and the -a option can be usedto specify a specific local address or port to listen to.

-a [address][:port]
Specify a specific address and port to listen to when called with the -loption. The default is to listen to the tftp port specified in /etc/services onall local addresses.

-c Allow new files to be created. By default, tftpd will only allow upload offiles that already exist. Files are created with default permissions allowinganyone to read or write them, unless the -p or -U options are specified.

-s (决定tftp根目录)Change rootdirectory on startup. This means the remote host does not need to pass alongthe directory as part of the trans-fer, and may add security. When -s isspecified, exactly one directory should be specified on the command line. Theuse of this option is recommended for security as well as compatibility withsome boot ROMs which cannot be easily made to include a directory name in itsrequest.
启动tftp 服务
sudo service tftpd-hpa restart

摘抄博友:

(1)关于重启 某个服务,之前的Linux(Ubuntu是10.10之前)都是这样操作的:
sudo /etc/init.d/XXX reload
对于inetd来说,就是:
sudo /etc/init.d/inetd reload
现在新的Ubuntu 10.10以后,是统一成调用service来操作了:
sudo service XXX restart
其中,启动和停止对应的是start和stop。
(2)记得不要少了sudo,否则“stop: Rejected send message”的错误。
(3)【确认tftp服务是否已经开启】
查看tftp相关进程:输入 $ psaux |grep tftp出现 root 3826 0.0 0.0 2352 120 ? Ss 14:270:00 /usr/sbin/in.tftpd --listen --user --address 0.0.0.0:69 --secure/home/crifan/develop/tftpboot usr 3828 0.0 0.0 5628 768 pts/0 S+14:27 0:00 grep --color=auto tftp
如果没有上面提示{sudo/etc/init.d/xinetd restartsudo/etc/init.d/tftpd-hpa restart}

验证tftp是否生效 tftp192.168.1.11 或者 127.0.0.1
tftp>get abc
tftp>quit
192.168.1.11通过 ifconfig 得出本机地址,127.0.0.1永远是本机地址get命令 是 从 tftpboot里面 下载 文件put 上传
你可以 建立在 home 目录下 建立一个 get文件夹,cd get然后 tftp 127.0.0.1
>get abc(abc是tftpboot 里面已经存在的文件),然后
>q退出ls看到 get文件夹下面是不是已经有了 abc文件。注意把get文件夹 的权限设置 为 可写 可执行。chmod 777 get

附:不成功现象及解决。
现象一:tftp>get fileTransfertimed out.原因:tftpd服务没有启动解决方法:启动服务sudo/etc/init.d/xinetd restartsudo/etc/init.d/tftpd-hpa restart现象二:tftp>get fileErrorcode 2: Only absolute filenames allowed原因:在/etc/xinetd.d/tftpd中设置的server_args为/etc/default/tftpd-hpa下面是我的机器上/etc/default/tftpd-hpa配置#/etc/default/tftpd-hpa
RUN_DAEMON="yes"
TFTP_ADDRESS="0.0.0.0:69"
OPTIONS="-s /home/tftpd -c -p -U 077 -u tftpd"
现象三:tftp>put fileErrorcode 1: File not found原因:指定的文件不存在;或tftpd启动参数中没有指定-c选项,允许上传文件~上传的时候一定要确保文件先存在于上传目录下。
现象四:tftp>get filetftp: : Permission denied原因:权限不足请查看chmod 是不是配置好
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ubuntu tftp