vsftpd-2.3.4服务器在ok6410开发板上的移植
老房原创修改版,在房老师教程基础上修改而成。
老房原创,转载声明,熬夜至凌晨2点捣鼓不容易啊!
我的环境飞凌OK6410开发板,arm-linux-gcc 4.3.2(我一般用的开发工具不新不旧)
--------------------------------------传-说-中-的-分-割-线-------------------------------------------------
1 、下载
Ubuntu上的ftp客户端软件filezilla
安装:
sudoapt-get installfilezilla
安装完成后,在应用程序->互联网会看到
采用ftp客户端filezilla下载:ftp://vsftpd.beasts.org/users/cevans/untar/下载vsftpd-2.3.4
2 、修改Makefile文件
CC=arm-linux-gcc
3 、执行make
若出现错误------------------------------------------
/bin/sh:./vsf_findlibs.sh: Permission denied
sysdeputil.o: In function`vsf_sysdep_check_auth':
sysdeputil.c:(.text+0xdcc): undefinedreference to `crypt'
sysdeputil.c:(.text+0xdf0): undefinedreference to `crypt'
collect2: ld returned 1 exit status
make:*** [vsftpd] 错误1
修改./vsf_findlibs.sh属性为可读写与执行
-------------------------------------------------------------
/lib/libcap.so.2:could not read symbols: File in wrong format
collect2: ld returned1 exit status
make: *** [vsftpd] 错误1
修改vsffindlibs.sh:
屏蔽掉49-57行;
------------------------------------------------------------------------
如果之后再出现
sysdeputil.o:In function `vsf_sysdep_check_auth':
sysdeputil.c:(.text+0xdcc):undefined reference to `crypt'
sysdeputil.c:(.text+0xdf0):undefined reference to `crypt'
collect2: ld returned 1 exitstatus
make: *** [vsftpd] 错误 1
那么就把/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/lib/下的libcrypt.so.1复制到开发板根文件系统/lib目录下
至于为什么这么处理我也想不明白。
4 、执行arm-linux-readelf-d vsftpd显示需要哪些库,如下:
Dynamicsection at offset 0x170fc contains 29 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libcrypt.so.1]
0x00000001(NEEDED) Shared library: [libc.so.6]
0x0000000c(INIT) 0x9680
0x0000000d(FINI) 0x1b3f4
0x00000019(INIT_ARRAY) 0x26a58
0x0000001b(INIT_ARRAYSZ) 4 (bytes)
0x0000001a(FINI_ARRAY) 0x26a5c
0x0000001c(FINI_ARRAYSZ) 4 (bytes)
0x00000004(HASH) 0x8168
0x00000005(STRTAB) 0x8d08
0x00000006(SYMTAB) 0x84f8
0x0000000a(STRSZ) 1100 (bytes)
0x0000000b(SYMENT) 16 (bytes)
0x00000015(DEBUG) 0x0
0x00000003(PLTGOT) 0x26b54
0x00000002(PLTRELSZ) 984 (bytes)
0x00000014(PLTREL) REL
0x00000017(JMPREL) 0x92a8
0x00000011(REL) 0x9298
0x00000012(RELSZ) 16 (bytes)
0x00000013(RELENT) 8 (bytes)
0x6ffffffe(VERNEED) 0x9258
0x6fffffff(VERNEEDNUM) 2
0x6ffffff0(VERSYM) 0x9154
0x00000000(NULL) 0x0
把libcrypt.so.1l libc.so.6 及这两个连接所指向的源文件用cp-a 复制到根文件系统的/lib
另外还有libnss_files.so.2及该连接所指向的源文件, 否则运行时会出现:
500OOPS: vsftpd: cannot locate user specified in'ftp_username':ftp
错误;(这点错误弄了一晚上好几个小时)ps:好帅老师辛苦了
5 、把生成的vsftpd拷贝到根文件系统的sbin目录,vsftpd.conf文件拷贝到根文件系统的etc目录下
6 、配置vsftpd.conf
对配置文件进行了修改,我的:
#Example config file /etc/vsftpd.conf
#
# The default compiledin settings are fairly paranoid. This sample file
# loosens thingsup a bit, to make the ftp daemon more usable.
# Please seevsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: Thisexample file is NOT an exhaustive list of vsftpd options.
# Pleaseread the vsftpd.conf.5 manual page to get a full idea of vsftpd's
#capabilities.
#
# Allow anonymous FTP? (Beware - allowed bydefault if you comment this out).
anonymous_enable=YES
#
#Uncomment this to allow local users to log in.
local_enable=YES
#
#Uncomment this to enable any form of FTP writecommand.
write_enable=YES
#
# Default umask for local usersis 077. You may wish to change this to 022,
# if your users expectthat (022 is used by most other ftpd's)
#local_umask=022
#
#Uncomment this to allow the anonymous FTP user to upload files. Thisonly
# has an effect if the above global write enable isactivated. Also, you will
# obviously need to create a directorywritable by the FTP user.
anon_upload_enable=YES
#
#Uncomment this if you want the anonymous FTP user to be able tocreate
# new directories.
anon_mkdir_write_enable=YES
#
#Activate directory messages - messages given to remote users whenthey
# go into a certain directory.
dirmessage_enable=YES
#
#Activate logging of uploads/downloads.
#xferlog_enable=YES
#
#Make sure PORT transfer connections originate from port 20(ftp-data).
connect_from_port_20=YES
#
# If you want, youcan arrange for uploaded anonymous files to be owned by
# adifferent user. Note! Using "root" for uploaded files isnot
# recommended!
#chown_uploads用户指定anonymous帐号上传的文件是否要改变其所有者,默认为NO,chown_username用来指定新的所有者
#在FTP服务器中,匿名用户的用户名和密码都是ftp
chown_uploads=YES
chown_username=ftp
#
#You may override where the log file goes if you like. The default isshown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# Ifyou want, you can have your log file in standard ftpd xferlogformat
xferlog_std_format=YES
#
# You may change the defaultvalue for timing out an idle session.
#idle_session_timeout=600
#
#You may change the default value for timing out a dataconnection.
#data_connection_timeout=120
#
# It isrecommended that you define on your system a unique user which the
#ftp server can use as a totally isolated and unprivilegeduser.
nopriv_user=ftp
#
# Enable this and the server willrecognise asynchronous ABOR requests. Not
# recommended forsecurity (the code is non-trivial). Not enabling it,
# however,may confuse older FTP clients.
async_abor_enable=YES
#
# Bydefault the server will pretend to allow ASCII mode but in factignore
# the request. Turn on the below options to have the serveractually do ASCII
# mangling on files when in ASCII mode.
#Beware that on some FTP servers, ASCII support allows a denial ofservice
# attack (DoS) via the command "SIZE /big/file"in ASCII mode. vsftpd
# predicted this attack and has always beensafe, reporting the size of the
# raw file.
# ASCII mangling isa horrible feature of theprotocol.
ascii_upload_enable=YES
ascii_download_enable=YES
#
#You may fully customise the login banner string:
ftpd_banner=Welcometo blah FTP service.
#
# You may specify a file of disallowedanonymous e-mail addresses. Apparently
# useful for combattingcertain DoS attacks.
#deny_email_enable=YES
# (defaultfollows)
#banned_email_file=/etc/vsftpd.banned_emails
#
#You may specify an explicit list of local users to chroot() to theirhome
# directory. If chroot_local_user is YES, then this listbecomes a list of
# users to NOTchroot().
#chroot_list_enable=YES
# (defaultfollows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# Youmay activate the "-R" option to the builtin ls. This isdisabled by
# default to avoid remote users being able to causeexcessive I/O on large
# sites. However, some broken FTP clientssuch as "ncftp" and "mirror" assume
# thepresence of the "-R" option, so there is a strong case forenablingit.
ls_recurse_enable=YES
#使vsftpd处于独立启动模式
listen=YES
listen_port=21
anon_other_write_enable=YES
7 、开发板根文件系统创建必要的目录:
mkdir-p /var/ftp/pub
mkdir -p /usr/share/empty
chown root:root/var/ftp
chmod 755 /var/ftp
cd /var/ftp
chmod 777 pub
说明:
pub这个目录是用来供匿名用户上传文件的,上传的文件存放在此处,故其属性为777,而其他目录无此属性,不能用来作为上传目录。
8 、创建用户
/etc/group文件至少要有root:
root:*:0:
/etc/passwd文件增加ftp和nobody用户:
root::0:0:root:/:/bin/sh
ftp::14:50:FTPUser:/var/ftp:
nobody:*:99:99:Nobody:/:
说明:
root:*:0:
root是用户组名称,*是密码字段,0是GID。
root::0:0:root:/:/bin/sh
root是用户名;
后面冒号之间的空白是密码字段,这里是空;
后面两个0分别是UID和GID;
再后面分别指定了root的家目录为/和要登录的shell为/bin/bash。
ftp::14:50:FTPUser:/var/ftp:
ftp是用户名;
冒号之间是密码字段,是隐藏的;
14是用户的UID字段,可以自己来设定,不要和其它用户的UID相同,否则会造成系统安全问题;
50用用户组的GID,可以自己设定,不要和其它用户组共用FTP的GID,否则会造成系统全全问题;FTPUser是用户说明字段,可以随意取名;
/var/ftp是ftp用户的家目录,可以自己来定义;
后面的shell字段为空,应该是不能登录shell;
(如果 shell 字段设置为 /sbin/nologin 表示该用户不能登录系统,系统虚拟帐号(也被称为伪用户)一般都是这么设置。如果我们把 ftp 用户的 /sbin/nologin改为/bin/bash,这样ftp 用户通过本地或者远程工具ssh 或 telnet 以真实用户身份登录到系统。这样做对系统来说是不安全的)
9. 开发板执行vsftpd/etc/vsftpd.conf&启动ftp,输入帐号名和密码即登入;
用户名root密码空,可访问开发板任意目录;
用户名anonymous密码空,可访问/var/ftp/pub目录
用户名ftp密码空,可访问/var/ftp/pub目录
说明:
(摘自网络)
当我们访问各大FTP上访问时,可能我们不去想我们以什么身份登录的,如果他的FTP允许匿名登录的话;比如我们在浏览器上打入;
ftp://mirrors.kernel.org
或
ftp://ftp:ftp@mirrors.kernel.org
我们会发现上面的两行最终都能访问,而且显示的结果也完全一样,最终都跳到ftp://mirrors.kernel.org地址;那我们访问这个FTP时,是不是有用户和密码呢?是的,也是需要在的,只是在服务器端允许匿名访问,而匿名访问的用户名和密码都是ftp,只是我们因为匿名访问,没有感觉到他有用户名和密码罢了。第二个地址就是以ftp用户,密码也是ftp来访问ftp://mirrors.kernel.org;
如果我们以ftp命令连接mirrors.kernel.org时,我们会发现需要输入用户ftp,密码ftp才能访问;
在FTP服务器中,匿名用户的用户名和密码都是ftp;这个用户可以在您的操作系统中的/etc/passwd中能找得到。
可采用最先开始安装的filezilla测试!!
参考资料:
http://www.linuxsir.org/main/node/152
http://apps.hi.baidu.com/share/detail/50310481
http://blog.sina.com.cn/s/blog_498719980100092k.html
以及老房原创原文:
http://user.qzone.qq.com/117482672#!
更多推荐
所有评论(0)