开发板添加ftp服务

参考:【1】https://www.linuxidc.com/Linux/2012-03/56781.htm
【2】https://blog.csdn.net/aaa794708075/article/details/80708126
内容和原问基本一样,只是自己整理了一下。
有两种源码实现方法:stupid-ftpd;vsftpd。找了一下vsftpd的源码压缩包没找到,就是用了stupid-ftpd,想用vsfpd的可以第二个参考。

stupid-vsftpd下载:

https://linux.linuxidc.com/index.php?folder=MjAxMsTq18rBzy8z1MIvMTbI1S/Htsjryr1MaW51eLXERlRQt/7O8bbLyO28/ihzdHVwaWQtZnRwZCk=

使用方法:

tar -xvf stupid-ftpd-1.5beta.tar.gz
cd stupid-ftpd
修改Makefile的
cc = arm-linux-gcc (使用交叉编译放到开发板)

CFLAGS=-O2 -Wall -Wstrict-prototypes -static(只是末尾添加-static 静态编译,如果不静态编译这里就不改了)

然后编译 make,生成stupid-ftpd.Linux6,静态编译大小是200多k,动态编译没试。然后把stupid-ftpd.Linux6复制到开发板的目录中,在目录中创建配置文件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=<login> <passwd> <subdir> <maxlogins> <flags>  
#       <login>     user name  
#       <passwd>    password or * for anonymous access  
#       <subdir>    (internally appended to serverroot)  
#               the user has access to the WHOLE SUBTREE,  
#               if the server has access to it  
#               <maxlogins> maximal logins with this usertype  
#       <flags>     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 进入ftpd> 就是ftp在服务中了。
执行完stupid-ftpd.Linux6 -f stupid-ftpd.conf 会出现几十行的 Warning: line ignored: 这句打印是在ftpdconfig.c中的273行,原因是在line中检索’='不成功导致的,后面使用不影响。还不知道怎么改配置文件才能消除警告,有知道的请告诉先谢谢了。

if ((p=strchr(line,'='))==NULL) {
      printf("Warning: line ignored: %s\n",line);
      continue;
    }

在“我的电脑”路径的框中输入ftp://192.168.x.x (开发板IP),就可以向开发板传输文件了。

问题

1、没搞懂怎么添加用户和密码;
2、在配置文件中stupid-ftpd.conf serverroot=/mnt,注释说是ftp访问的是/mnt目录,但电脑打开是根目录 / ,不解。

补充

stupid-ftpd好像就是不能添加本地用户的,后来又到网上找了vsftpd,找了好一会才找到。给各位下载地址 https://www.xiazaiba.com/html/4351.html 自己还没移植试过,有问题不负责。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值