浅析busybox内置的ftpd服务程序如何配置

来源:互联网 发布:淘宝上的图片怎么做的 编辑:程序博客网 时间:2024/06/06 05:57
 

server服务器配置
方法1:
# mkdir /gliethttp_ftpd_dir
# cp /bin/busybox /gliethttp_ftpd_dir
# tcpsvd 0 21 ftpd -w /gliethttp_ftpd_dir &
// 上面的0表示对所有ip地址都进行侦听
// 如果设置为127.0.0.1那么只能开发板本地arm可以进行ftp
// 比如开发板eth0的的ip地址设为172.20.0.2,那么就不能通过该ip登录
// 所以上面指定ip等于0,那么无论来自127.0.0.1还是172.20.0.2网络地址的
// 数据都能使用ftpd服务器.
// ftpd -w这里的参数-w表示client可以对目录执行写操作
// 可以使用-t和-T参数设置client在没有任何操作的最大时间之后ftpd主动断开client连接,即:Idle and absolute timeouts
// 默认-t为2分钟=2 * 60,-T为1小时=1 * 60 * 60

方法2:
# mkdir /gliethttp_ftpd_dir
# cp /bin/busybox /gliethttp_ftpd_dir
# vi /etc/inetd.conf
21 stream tcp nowait root ftpd ftpd -w /gliethttp_ftpd_dir
# inetd                 // inetd会执行/etc/inetd.conf脚本中的命令行,这样ftpd就作为daemon运行到起来了
(注意:以上2种方式运行的ftpd都不会在ps中看到ftpd进程的运行)


//========================================================
client客户端测试

在pc机上直接ftp数据
luther@gliethttp:~$ ftp 172.20.0.2
Connected to 172.20.0.2.
220 Operation successful
Name (172.20.0.2:luther): 
230 Operation successful
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 Operation successful
150 Directory listing
-rwxr-xr-x    1 0                826724 Jan 1 00:02 busybox
226 Operation successful
ftp> put uda1341ts.tar.bz2          // 将uda1341ts.tar.bz2文件上传到开发板的/gliethttp_ftpd_dir目录下
local: uda1341ts.tar.bz2 remote: uda1341ts.tar.bz2
200 Operation successful
150 Ok to send data
226 Operation successful
485435 bytes sent in 0.12 secs (3809.5 kB/s)
ftp> ls
200 Operation successful
150 Directory listing
-rwxr-xr-x    1 0                826724 Jan 1 00:02 busybox
-rw-r--r--    1 0                485435 Jan 1 00:03 uda1341ts.tar.bz2       // 刚刚上传上上去的uda1341ts.tar.bz2文件
226 Operation successful
ftp> get busybox
local: busybox remote: busybox
200 Operation successful
150 Opening BINARY connection for busybox (826724 bytes)
226 Operation successful
826724 bytes received in 0.15 secs (5411.8 kB/s)
ftp> del busybox
250 Operation successful
ftp> ls
200 Operation successful
150 Directory listing
-rw-r--r--    1 0                485435 Jan 1 00:03 uda1341ts.tar.bz2
226 Operation successful
ftp> 


//当然也可以用window作为ftp的客户端登录到目标板上

 

 

 

实际使用过程更为简单:直接在/etc/init.d/rcS 这个文件里面加上如下指令即可

/sbin/tcpsvd -vE 0 21 /sbin/ftpd -w 【dir】 &

 

 

------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

启动方法1:

#tcpsvd 0 21 ftpd -w /root &

// 上面的0表示对所有ip地址都进行侦听

// ftpd -w这里的参数-w表示client可以对目录执行写操作

// 21指定ftp服务器的默认端口

// 可以使用-t和-T参数设置client在没有任何操作的最大时间之后ftpd主动断开client连接,

// 默认-t为2分钟=2 * 60,-T为1小时=1 * 60 * 60

 


启动方法2:

#vi /etc/inetd.conf //增加以下代码

  21  stream  tcp  nowait  root  ftpd  ftpd  -w  /root

#inetd                
//inetd会执行/etc/inetd.conf脚本中的命令行,这样ftpd就作为daemon运行到起来了

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2011-10/44724.htm

 

原创粉丝点击