通过stupid-ftpd在linux下建立ftp服务器

使用到的源码包为:stupid-ftpd-1.5beta.tar.gz
下载地址:
https://sourceforge.net/projects/stupid-ftpd/files/stupid-ftpd/V1_5beta/

1、解压源码包

tar -vxf stupid-ftpd-1.5beta.tar.gz

2、进入解压生成的stupid-ftpd目录
3、修改stupid-ftpd.conf配置文件

#serverroot=/usr/home/cinek/tmp3/aaa
serverroot=/home/ftp

#port=2121
port=21

4、make生成stupid-ftpd.Linux6脚本(不用make install)

在当前目录下执行

./stupid-ftpd.Linux6 -f stupid-ftpd.conf

可以看到如下消息

root@ubuntu:/home/chemi/neo/ftp/stupid-ftpd# ls
BUILD.AIX     command.h     ftpdconfig.c  Makefile          Makefile.win      stupid-ftpd.h
BUILD.Linux5  command.o     ftpdconfig.h  Makefile.AIX      README            Stupid-FTPD.INI
BUILD.Linux6  COPYING       ftpdconfig.o  Makefile.Linux5   servercommand.c   stupid-ftpd.Linux6
BUILD.SCO     CREDITS       ftperror.h    Makefile.Linux6   servercommand.h   stupid-ftpd.o
BUILD.SunOS   ftpcommand.c  ls.c          Makefile.SCO      TODO
CHANGES       ftpcommand.h  ls.h          Makefile.Solaris  stupid-ftpd.c
command.c     ftpcommand.o  ls.o          Makefile.SunOS    stupid-ftpd.conf
root@ubuntu:/home/ftp/stupid-ftpd# ./stupid-ftpd.Linux6 -f stupid-ftpd.conf
User anonymous registered.
Starting server ... OK

*ftpd> 

此时ftp服务器就运行起来了。该系统的ip地址为“192.168.0.71”

验证

① 在另一个终端上执行:ftp 192.168.0.71
用户名输入:anonymous
密码输入: (空格)
如下所示

root@ubuntu:/home# ftp 192.168.0.71
Connected to 192.168.0.71.
220 Welcome to Stupid-FTPd server.
Name (192.168.0.71:root): anonymous
331 Guest login ok, send your e-mail address as password.
Password:
230 User anonymous logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful.
150 OK
drwxr-xr-x   3 anonymous ftp          4096 Nov 30 03:52 test
drwxr-xr-x   3 anonymous ftp          4096 Nov 30 06:19 stupid-ftpd
-rw-r--r--   1 anonymous ftp         34487 Nov 29 11:47 stupid-ftpd-1.5beta.tar.gz
226 Transfer complete.
ftp> 

② 在浏览器上输入:ftp://192.168.0.71/
如下图所示
在这里插入图片描述

③ 在计算机地址栏输入:ftp://192.168.0.71/
如下图所示
在这里插入图片描述

如果修改Makefile中CC=gcc 为自己的交叉编译器,即可以编译出在板子上运行的ftp服务器。

通过以上操作,可以方便在主机之间传递文件(当然,使用最多还是ssh)。

具体ftp的get文件和put文件操作,可以参考:
https://linux.cn/article-6746-1.html

参考链接:
https://blog.csdn.net/u011251940/article/details/78781952

2018.12.3更新:
自己配置使用的Makefile:


#
# 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=/home/neo/ftp

# type of chroot
# real    - kernel chroot(), high security, but needs root privileges
# virtual - no real chroot(), software side (virtual) chroot

changeroottype=real


# Port number for the FTP-Protocol

#port=2121
port=21


# 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
#user=neo neo /home/neo/ftp/test  5   A
user=neo neo /  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

猜你喜欢

转载自blog.csdn.net/weixin_38184741/article/details/84649740
今日推荐