QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 723|回复: 4

vsftpd虚拟用户的问题

[复制链接]
发表于 2005-3-7 22:17:17 | 显示全部楼层 |阅读模式
创建guest用户

  VSFTPD采用PAM方式验证虚拟用户。由于虚拟用户的用户名/口令被单独保存,因此在验证时,VSFTPD需要用一个系统用户的身份来读取数据库文件或数据库服务器以完成验证,这就是VSFTPD的guest用户。这正如同匿名用户也需要有一个系统用户ftp一样。当然,我们也可以把 guest用户看成是虚拟用户在系统中的代表。下面在系统中添加vsftpdguest用户,作为VSFTPD的guest。
  [root@hpe45 vsftpd-1.2.0]# useradd vsftpdguest
  当虚拟用户登录后,所在的位置为vsftpdguest的自家目录/home/vsftpdguest。如果要让虚拟用户登录到/var/ftp等其他目录,修改vsftpdguest的自家目录即可。

  三、设置VSFTPD配置文件

  在/etc/vsftpd.conf文件中,加入以下选项:
  guest_enable=YES
  guest_username=vsftpdguest

  然后执行以下命令,让VSFTPD在后台运行:
  [root@hpe45 vsftpd-1.2.0]# /usr/local/sbin/vsftpd &

  四、将虚拟用户保存在MySQL数据库服务器中

  我们建立数据库vsftpdvu,表users,字段name和passwd用于保存虚拟用户的用户名和口令,同时增加两个虚拟用户xiaotong和xiaowang。

  [root@hpe45 vsftpd-1.2.0]# mysql -p
  mysql>create database vsftpdvu;
  mysql>use vsftpdvu;
  mysql>create table users(name char(16) binary,passwd char(16) binary);
  mysql>insert into users (name,passwd) values ('xiaotong',password('qqmywife'));
  mysql>insert into users (name,passwd) values ('xiaowang',password('ttmywife'));
  mysql>quit

  然后,授权vsftpdguest可以读vsftpdvu数据库的users表。执行以下命令:
  [root@hpe45 vsftpd-1.2.0]# mysql -u root mysql -p
  mysql>grant select on vsftpdvu.users to vsftpdguest@localhost identified by 'i52serial0';
  mysql>quit

  如果要验证刚才的操作是否成功可以执行下面命令:
  [root@hpe45 vsftpd]#mysql -u vsftpdguest -pi52serial0 vsftpdvu
  mysql>select * from users;
  如果成功,将会列出xiaotong、xiaowang和加密后的密码

  五、设置MySQL的PAM验证

  这里我们要用到一个利用mysql进行pam验证的开源项目(http://sourceforge.net/projects/pam-mysql/)。首先从网站下载它的程序包pam_myql-0.5.tar.gz,复制到/root目录中。在编译安装之前,要确保mysql-devel的RPM包已经安装在你的机器上,如果没有请从RHL安装光盘中安装该包。然后,执行以下命令:
  [root@hpe45 root]#tar xvzf pam_mysql-0.5.tar.gz
  [root@hpe45 root]#cd pam_mysql
  [root@hpe45 pam_mysql]#make
  [root@hpe45 pam_mysql]#make install
  make install这一步可能会出现错误,那只好手动将该目录下生成的pam_mysql.o复制到/lib/security目录下。
  接下来,我们要设置vsftpd的PAM验证文件。打开/etc/pam.d/vsftpd文件,加入以下内容:
  auth required pam_mysql.o user=vsftpdguest passwd=i52serial0 host=localhost db=vsftpdvu table=users usercolumn=name passwdcolumn=passwd crypt=2
  account required pam_mysql.o user=vsftpdguest passwd=i52serial0 host=localhost db=vsftpdvu table=users usercolumn=name passwdcolumn=passwd crypt=2
  上面涉及到的参数,只要对应前面数据库的设置就可以明白它们的含义。这里需要说明的是crypt参数。crypt表示口令字段中口令的加密方式: crypt=0,口令以明文方式(不加密)保存在数据库中;crypt=1,口令使用UNIX系统的DES加密方式加密后保存在数据库中;crypt= 2,口令经过MySQL的password()函数加密后保存。
 楼主| 发表于 2005-3-7 22:22:14 | 显示全部楼层
我是根据上面的文章来配制虚拟用户的
但是用我创建的ighack却连不上
回复

使用道具 举报

 楼主| 发表于 2005-3-9 17:44:29 | 显示全部楼层
救命啊
回复

使用道具 举报

 楼主| 发表于 2005-3-14 23:15:55 | 显示全部楼层
/etc/pam.d/vsftpd的文内容



#%PAM-1.0
auth       required        pam_listfile.so item=user sense=deny file=/etc/vsftpd.ftpusers onerr=succeed
auth       required        pam_stack.so service=system-auth
auth       required        pam_shells.so
account    required        pam_stack.so service=system-auth
session    required        pam_stack.so service=system-auth
auth required /lib/security/pam_mysql.o user=vsftpdguest pass=123456ab host=localhost db=vsftpd table=user usercolumn=name passwdcolumn=pass crypt=2
  account required /lib/security/pam_mysql.o user=vsftpdguest pass=123456ab host=localhost db=vsftpd table=user usercolumn=name passwdcolumn=pass crypt=2
回复

使用道具 举报

 楼主| 发表于 2005-3-14 23:17:13 | 显示全部楼层
/etc/vsftpd/vsftp.conf


# Example config file /etc/vsftpd/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=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# 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 will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# 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, 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 shown
# 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
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command "SIZE /big/file" in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# 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
#
# 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" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES

pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES
listen_port=2121
anon_max_rate=10000
local_max_rate=100000
virtual_use_local_privs=NO
guest_enable=YES
guest_username=vsftpdguest
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-6 08:09 , Processed in 0.098744 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

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