在嵌入式Linux系统中,有时候需要搭建一个ftp服务器,以便windows或linux系统去访问嵌入式linux系统的数据。现在流行的ftp和vsftpd软件相对比较大,并且 vsfpd 配置起来比较麻烦,推荐一款易用的 tfp 工具:stupid-ftpd
解压之后修改makefile:
- #
- #
- # Makefile for the linux version of stupid-ftpd
- #
- #
- #
-
-
- CC=arm-linux-gcc #修改
- OBJS=ftpcommand.o ftpdconfig.o command.o ls.o stupid-ftpd.o
- DOBJS=ftpcommand.do ftpdconfig.do command.do ls.do stupid-ftpd.do
- POBJS=ftpcommand.po ftpdconfig.po command.po ls.po stupid-ftpd.po
- LIBS=
- CFLAGS=-O2 -Wall -Wstrict-prototypes -static #修改
- DCFLAGS=-g -DDEBUG -Wall -Wstrict-prototypes
- PCFLAGS=-g -DDEBUG -Wall -Wstrict-prototypes -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs
- EXEC=stupid-ftpd.Linux6
-
- .SUFFIXES: .c .o .do .po
-
- all: $(OBJS)
- $(CC) $(CFLAGS) -o $(EXEC) $(OBJS) $(LIBS)
-
- debug: $(DOBJS)
- $(CC) $(DCFLAGS) -o $(EXEC) $(DOBJS) $(LIBS)
-
- pedantic: $(POBJS)
- $(CC) $(PCFLAGS) -o $(EXEC) $(POBJS) $(LIBS)
-
- clean:
- rm -f $(OBJS) $(DOBJS) $(POBJS) $(EXEC) *~
-
- .c.o:
- $(CC) $(CFLAGS) -c -o $@ [ DISCUZ_CODE_0 ]lt;
-
- .c.do:
- $(CC) $(DCFLAGS) -c -o $@ [ DISCUZ_CODE_0 ]lt;
-
- .c.po:
- $(CC) $(PCFLAGS) -c -o $@ [ DISCUZ_CODE_0 ]lt;
-
- install:
- install -m 755 -s ./stupid-ftpd /usr/local/bin/stupid-ftpd
- install -m 700 -d /etc/stupid-ftpd
- install -m 755 -d /usr/local/stupid-ftpd
- install -m 600 ./stupid-ftpd.conf /etc/stupid-ftpd/stupid-ftpd.conf
复制代码
make
编译完成后,生成stupid-ftpd.Linux6可执行程序,拷贝到开发板 /bin 目录
此外,它需要一个配置文件,将以下东东存为 /etc/stupid-ftpd.conf
- #
- # This is a config-file for stupid-ftpd
- # ------------------------------------
- #
- # The standard path should be /etc/stupid-ftpd.conf
- # You can define other paths by using the "-f" option
- # when starting stupid-ftpd.
- #
- #
- # ATTENTION: 1) Remember, that the server is running with YOUR permissions.
- # It will fail to access other users directory, unless it is
- # root, but it also allows to access ALL YOUR directories,
- # which are deeper in a user's root-dir and YOU HAVE access to.
- # 2) To solve the problem, the best way is to define a group-ID
- # for stupid-ftpd.
- # Or if you aren't root: set the MAIN root (serverroot=) to
- # the highest directory depth which is possible.
- # 3) REMEMBER: DO NOT PUT THIS FILE in an accessible directory!!!
- # There are passwords defined here. The safest place is
- # outside the serverroot.
-
-
- # Server operation mode:
- # daemon - quiet in background
- # interactive - standard mode
-
- #mode=interactive #交互式的形式运行
- mode=daemon #以守护进程的形式运行在后台
-
- # chroot to
-
- #serverroot=/usr/home/cinek/tmp3/aaa
- serverroot=/mnt #将ftp的根目录设置为/mnt目录下,在windows打开该ftp,就能访问/mnt目录
-
- # type of chroot
- # real - kernel chroot(), high security, but needs root privileges
- # virtual - no real chroot(), software side (virtual) chroot
-
- #changeroottype=real
- changeroottype=virtual
-
-
- # Port number for the FTP-Protocol
-
- #port=2121
- port=21 #默认为ftp的端口号。
-
-
- # Maximum users allowed to log in
-
- maxusers=10
-
-
- # Message Of The Day (motd)
- # It will be displayed after the login procedure.
-
- #motd=/tmp/stupid-ftpd.motd
-
-
- # Message on quit
- # It will be displayed when quitting.
-
- #byemsg=/tmp/stupid-ftpd.bye
-
-
- # Log
-
- #log=/tmp/stupid-ftpd.log
-
-
- # User list:
- # Format: user=
- # user name
- # password or * for anonymous access
- # (internally appended to serverroot)
- # the user has access to the WHOLE SUBTREE,
- # if the server has access to it
- # maximal logins with this usertype
- # D - download
- # U - upload + making directories
- # O - overwrite existing files
- # M - allows multiple logins
- # E - allows erase operations
- # A - allows EVERYTHING(!)
- #
- # user ftp is mapped to user anonymous, don't forget this
- #
- # Examples:
- # user=user1 passx /tmp 2 D
- # - login: user1, passwd: passx, max login twice (different IPs!)
- # only download rights from directory /tmp
- # user=user2 passy /home/user2 0 DU
- # - login: user2, passwd: passy, no login count limit (different IPs!)
- # download+upload rights to directory /home/user2
- # user=user3 passz /home/user3 5 DUOM
- # - login: user3, passwd: passz, max login count 5 (even from same IP)
- # download+upload+overwrite rights to directory /home/user3
- # user=user4 passq /tmp 10 -
- # - login: user4, passwd: passq, max login count 10 (even from same IP)
- # look-only rights at directory /tmp
- #
- # SEE: ATTENTION remark on the top of this file !!!
-
- user=anonymous * / 5 A
-
-
- # Banned hosts
- # "*" and "?" are allowed here
-
- #ban=192.168.*
- #ban=localhost
- #ban=*.banme.com
-
-
- # Ban message (displayed to user who is banned)
- # Please don't use more than 70 characters.
-
- #banmsg=Go away !
-
-
- # Login/password timeout
-
- login-timeout=120
-
-
- # Timeout (while logged in)
-
- timeout=240
复制代码
然后执行 stupid-ftpd.Linux6 -f stupid-ftpd.conf
执行的时候可能会出现十几行警告信息,把 stupid-ftpd.conf 中的空白行删掉即可
此外,它有两种模式,一种是后台模式,一种是交互模式,配置中默认使用的是后台模式,但是我在测试过程中有些问题,
我修改了代码:
ftpdconfig.c Line 56
- int daemonmode=0;
+ int daemonmode=1;
---------------------------------------
配置信息中,
user=anonymous * / 5 A
字段,表明支持匿名登录,不需要密码
打开浏览器,输入:ftp:\开发板ip
点击匿名登录,即可
当然你可以配置一下用户名和密码,例如:user=linux linux / 5 A
------------------------------------------------------------------------------------------
可以使用 filezilla 进行文件上传下载
配置站点信息的地方需要注意一下:不要选择加密的,选择xxxftp(不安全的)----具体写的啥记不清了,懒得下载了