LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1134|回复: 2

vsftpd-1.2.0 on freebsd5.1 上虚拟用户设置的最后一个问题

[复制链接]
发表于 2003-8-7 18:19:45 | 显示全部楼层 |阅读模式
我按照
http://chinaunix.net/forum/viewt ... 9%C4%E2%D3%C3%BB%A7

这个帖子的内容一步步转移到FREEBSD5.1系统上来,到了最后一步了,却无法登陆,很邪门。请大家指导一下。我建立的FTP地址为ftp.dragonson.org:10021

我的安装步骤如下:


一,安装vsftpd-1.2.0
ftp://vsftpd.beasts.org/users/cevans/ 下载vsftpd-1.2.0.tar.gz到我的服务器目录/usr/home/peng/src下

www# cd /usr/home/peng/src
www#tar -zvxf vsftpd-1.2.0.tar.gz
www#cd vsftpd-1.2.0
www#make
www#make install

结果出现如下错误:

if [ -x /usr/local/sbin ]; then install -m 755 vsftpd /usr/local/sbin/vsftpd; else install -m 755 vsftpd /usr/sbin/vsftpd; fi
if [ -x /usr/local/man ]; then install -D -m 644 vsftpd.8 /usr/local/man/man8/vsftpd.8; install -D -m 644 vsftpd.conf.5 /usr/local/man/man5/vsftpd.conf.5; elif [ -x /usr/share/man ]; then install -D -m 644 vsftpd.8 /usr/share/man/man8/vsftpd.8; install -D -m 644 vsftpd.conf.5 /usr/share/man/man5/vsftpd.conf.5; else install -D -m 644 vsftpd.8 /usr/man/man8/vsftpd.8; install -D -m 644 vsftpd.conf.5 /usr/man/man5/vsftpd.conf.5; fi
install: illegal option -- D
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...
*** Error code 64

Stop in /usr/home/peng/src/vsftpd-1.2.0.
www#

其实安装过程中执行了如下操作而已:
www#cp vsftpd /usr/local/sbin/vsftpd
www#cp vsftpd.conf.5 /usr/local/man/man5
www#cp vsftpd.8 /usr/local/man/man8
www#cp xinetd.d/vsftpd /etc/xinetd.d/    [说明:因为我不打算采用xinetd方式运行FTP,以下手动执行命令的时候,我没执行这行命令]

所以我就手动执行以上命令,避开make install的错误(但是我不知道为什么make install会出现错误,高手指点一下)

接着,我执行复制默认配置文件到/etc目录下
www#cp vsftpd.conf /etc


二,安装Berkeley db program
默认的freebsd5.1下好象没db,所以我下了个,地址如下:http://www.sleepycat.com/update/snapshot/db-4.1.25.tar.gz

www#cd /usr/home/peng/src/
www#tar -zvxf db-4.1.25.tar.gz
www#cd db-4.1.25/build_unix
www#../dist/configure
www#make
www#make install

就这样完成了db的安装

三,生成虚拟用户口令库文件

首先,建立一个文本文件,里面含有虚拟用户的用户名和密码,单数行为用户名,偶数行为密码,比如说我要建立soft的用户名和以及它的密码为soft,则执行如下命令
www#vi /root/logins.txt

#以下为logins.txt的内容
soft    #虚拟用户名
soft    #该虚拟用户名的密码
然后执行wq!保存退出

接着,我先建立了一个目录来存放口令库文件,然后使用db_load命令来生成口令库文件,命令如下:

www#mkdir /etc/vsftpd
www#/usr/local/BerkeleyDB.4.1/bin/db_load -T -t hash -f /root/logins.txt /etc/vsftpd/vsftpd_login.db

这样在/etc/vsftpd目录下就多了个口令库文件vsftpd_login.db

四,编辑生成虚拟用户所需要的pam配置文件
www#vi /etc/pam.d/ftp.vu

敲入如下内容,并保存退出

auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login

请注意,上面敲入内容中db=后面的路径为/etc/vsfptd/vsftpd_login,因为要与前面使用db_load命令时候生成口令库的路径一致。


五,建立虚拟用户所要访问的目录,并设置仅virtual用户访问的权限
执行如下命令

www# mkdir /usr/home/ftpsite
www# pw useradd virtual -d /usr/home/ftpsite
www# ls -ld /usr/home/ftpsite
drwxr-xr-x 2 root wheel 512 Aug 7 13:53 /usr/home/ftpsite
www#

结果ls后,发现虚拟用户所要访问的目录还是ROOT所有,难道我的PW命令错误?

于是我就又执行
www# rm -rf /usr/home/ftpsite
www# pw useradd virtual -d /usr/home/ftpsite
pw: login name `virtual' already exists
www# pw userdel virtual
www# pw useradd virtual -d /usr/home/ftpsite
www# ls -ld /usr/home/ftpsite
ls: /usr/home/ftpsite: No such file or directory
www#


也就是说pw命令并没有建立/usr/home/ftpsite这个目录,看来我只能以root身份手动建立该目录。我这点一直没明白,高手指点我一下!


没办法,只好用chown,chgrp两个命令来变通一下拉
执行如下命令

www#chown virtual /usr/home/ftpsite
www#chgrp virtual /usr/home/ftpsite
www#chmod 700 /usr/home/ftpsite

六,生成vsftpd的配置文件
执行如下命令:

www#cp /etc/vsftpd.conf /etc/vsftpd/vsftpd.virtual.conf
www#vi /etc/vsftpd.virtual.conf
在该文件中添加或者修改,内容如下:
anonymous_enable=NO
local_enable=YES
write_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
ftpd_banner=Welcome to www.dragonson.org virtual FTP service.
chroot_local_user=YES
guest_enable=YES
guest_username=virtual
listen=YES
listen_port=10021
pasv_min_port=30000
pasv_max_port=30999
pam_service_name=ftp.vu

然后保存退出

该启动vsftpd服务了吧?于是,我迫不及待地执行了如下命令
www#/usr/local/sbin/vsftpd /etc/vsftpd/vsftpd.virtual.conf &

然后,我用cuteftp 来登陆我的这个vsftp服务器
主机名为 ftp.dragonson.org [ 已经通过www.net.cn解析到我的IP上 ]
用户名为 soft     [ 虚拟用户名 ]
密码为  soft       [虚拟用户名密码]
端口为 10021

激动人心的时刻到了吧?一点“连接”,倒~~~,cuteftp又出现如下登陆错误提示


                *** CuteFTP Pro 3.2 - build Jul  1 2003 ***

状态:>          正在获取列表“”...
状态:>          正在连接到 ftp 服务器 202.4.142.209:10021 (ip = 202.4.142.209)...
状态:>          Socket 已连接。正在等候欢迎消息...
                500 OOPS: vsftpd: not found: directory given in 'secure_chroot_dir':/usr/share/empty
错误:>           语法错误,命令未确认。


一看错误提示,好象我的/usr/share目录下没empty这个目录

于是,执行如下命令

www#mkdir /usr/share/empty
www#vi /etc/vsftpd/vsftpd.virtual.conf

添加如下一行

secure_chroot_dir=/usr/share/empty

保存退出,重新执行如下命令

www#/usr/local/sbin/vsftpd /etc/vsftpd/vsftpd.virtual.conf &

当然了,为了启动机器的时候自动运行vsftpd服务,我建立了一个自动启动的vsftpd脚本
执行如下命令:

www#cd /usr/local/etc/rc.d
www#vi vsftpd.sh

添加如下内容

/usr/local/sbin/vsftpd /etc/vsftpd/vsftpd.virtual.conf &

保存退出,执行如下命令:

www#chmod 777 ./vsftpd.sh
www#shutdown -r now

重新启动机器后,执行如下命令看vsftpd服务是否在运行

www#ps -ax | grep vsftpd

412 con- I      0:00.00 /usr/local/sbin/vsftpd /etc/vsftpd/vsftpd.virtua

我看不懂上面的con- I 是什么意思,似乎服务在运行着

于是继续通过cuteftp连接 我的vsftpd服务器,结果再次晕倒, cuteftp又出现如下登陆错误提示


        *** CuteFTP Pro 3.2 - build Jul  1 2003 ***

状态:>          正在获取列表“”...
状态:>          正在连接到 ftp 服务器 202.4.142.209:10021 (ip = 202.4.142.209)...
状态:>          Socket 已连接。正在等候欢迎消息...
                220 Welcome to www.dragonson.org virtual FTP service.
状态:>          已连接。正在验证...
命令:>          USER soft
                331 Please specify the password.
命令:>          PASS *****
                530 Login incorrect.
错误:>           未登录。
状态:>          连接已关闭。



就是说,那个soft的密码老是不正确,出现叫我重新输入密码的对话框,我真的没则了。

只差最后的一步拉,只好跪求上天赐予我论坛上的哪位高人指点迷津!!

高手啊,现身吧。
 楼主| 发表于 2003-8-7 18:20:47 | 显示全部楼层
以下是我的vsftpd.virtual.conf的配置文件

# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out
).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=NO
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you wi
ll
# obviously need to create a directory writable by the FTP user.
anon_upload_enable=NO
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is show
n
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Welcome to www.dragonson.org virtual FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparent
ly
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list

chroot_local_user=YES
guest_enable=YES
guest_username=virtual
listen=YES
listen_port=10021
pasv_min_port=30000
pasv_max_port=30999
pam_service_name=ftp.vu
secure_chroot_dir=/usr/share/empty
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assu
me
# the presence of the "-R" option, so there is a strong case for enabling i
t.
#ls_recurse_enable=YES
 楼主| 发表于 2003-8-8 09:17:28 | 显示全部楼层
高手说说话嘛
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表