如果这个问题都没法解决,这个论坛所谓的大神都是假的,我不相信,论坛能有人把这个问题解决了,我悬赏90QB打赌,详见38楼

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

如果这个问题都没法解决,这个论坛所谓的大神都是假的,我不相信,论坛能有人把这个问题解决了,我悬赏90QB打赌,详见38楼

#1

帖子 243750496 » 2013-07-06 21:39

屏幕截图.png
/etc/vsftpd.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.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=YES
#
# Run standalone with IPv6?
# Like the listen parameter, except vsftpd will listen on an IPv6 socket
# instead of an IPv4 one. This parameter and the listen parameter are mutually
# exclusive.
#listen_ipv6=YES
#
# Allow anonymous FTP? (Disabled by default)
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=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)
anon_umask=022
#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
#
# If enabled, vsftpd will display directory listings with the time
# in your local time zone. The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=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!
seccomp_sandbox=NO
chown_uploads=YES
chown_username=root
#
# 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.
# Note that the default log file location is /var/log/xferlog in this case.
#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 on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#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 restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# 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().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#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
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
anon_root=/home/cc/AAA
local_root=/home/cc/AAA
guest_enable=YES
guest_username=vsftpd
virtual_use_local_privs=NO
user_config_dir=/etc/vsftpd_user_conf
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
# This option specifies the location of the RSA key to use for SSL
# encrypted connections.
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

/etc/pam.d/vsftpd:
auth required pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
account required pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
上次由 243750496 在 2013-07-19 19:19,总共编辑 6 次。
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect

#2

帖子 243750496 » 2013-07-06 23:24

匿名用户也能登录,为什么就唯独系统用户登录不了?难道只能虚拟用户和匿名用户登录,系统用户被;屏蔽了?
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#3

帖子 243750496 » 2013-07-11 12:04

不知这篇帖子有用么,我重装后再试一下


本文参考了vsftpd安装文档,vsftpd的EXAMPLE及网上众多网友的文章。
环境:
匿名及本地用户:REDhatArray+vsftpd1.1.3(或vftpd2.0.1)。
虚拟用户:vsftpd1.1.3+mysql3.23.54+pam_mysql0.5
不适用于vsftpd2.0.1+mysql4+pam0.5。[/b]

[b:6b653ef73Array]请注意:不要直接copy我这里的配置文件,可以造成ftp启动不正常,所以还是多费点事,自己输入吧[/b:6b653ef73Array]

本文对本地用户、虚拟用户目录进行了限制,每个用户拥有自己独立的目录。
本文中所使用的参数具体意义请参数回贴。
配置不外就是修改vsftpc.conf,并指定用户目录,权限等。
对虚拟用户则用pam验证方式。

另:mkdir建立目录,chown更改权限。vi编辑文件。这些命令请参考man文档

[color=red:6b653ef73Array][b:6b653ef73Array]vsftpd类别:[/b:6b653ef73Array][/size:6b653ef73Array][/color:6b653ef73Array]

1、PORT FTP
首先会建立控制频道,默认值是port 21,也就是跟port 21 建立联机,并透过此联机下达指令。
第二,由FTP server 端会建立数据传输频道,默认值为20,也就是跟port 20 建立联机,并透过port 20 作数

据的传输。

2、PASVFTP
首先会建立控制频道,默认值是port 21,也就是跟port 21 联机,并透过此联机下达指令。
第二,会由client 端做出数据传输的请求,包括数据传输port 的数字。

3、差别:
PORT FTP 当中的数据传输port 是由FTP server 指定,
而PASV FTP 的数据传输port 是由FTP client 决定。
通常我们使用PASV FTP,是在有防火墙的环境之下,透过client 与server 的沟通,决定数据传输的port。



[color=red:6b653ef73Array][b:6b653ef73Array]vsftpd安装篇:[/b:6b653ef73Array][/size:6b653ef73Array][/color:6b653ef73Array]


1、rpm安装:
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;#rpm -ivh vsftpd-1.1.3-8.i386.rpm[/code:1:6b653ef73Array]

2、tar.gz的安装
解压后查看README和INSTALL文档

安装前的条件:

进入vsftpd目录
编辑 "builddefs.h"文件,里面定义了pam功能,tcp_wrappers功能,ssl功能,根据需要定义pam或tcpwrapper功能,以消ssl功能

然后键入 "make" .将编译出相应的二进制文件,你可以用以下命令查看
[chris@localhost vsftpd]$ ls -l vsftpd
-rwxrwxr-x 1 root root 61748 Sep 27 00:26 vsftpd

a、增加“nobody”用户。在系统中添加此用户,如果用户已经存在,useradd命令有相应提示。
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# useradd nobody [/code:1:6b653ef73Array]
useradd: user nobody exists

b、建立“/usr/share/empty”目录。在系统中此目录,如果目录已经存在,mkdir命令有相应提示。
[code:1:6b653ef73Array]&#Array1;root@hpe45 root&#Array3;# mkdir /usr/share/empty/ [/code:1:6b653ef73Array]
mkdir: cannot create directory ’/usr/share/empty’: File exists

c、匿名服务帐号:“ftp”用户和一个有效的匿名目录(默认为/var/ftp)。
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# mkdir /var/ftp/
&#Array1;root@Linux_win vsftpd&#Array3;# useradd -d /var/ftp ftp [/code:1:6b653ef73Array]

d、更改目录的所有者为root,并让ftp用户对自己的主目录不可写
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# chown root.root /var/ftp
&#Array1;root@Linux_win vsftpd&#Array3;# chmod og-w /var/ftp [/code:1:6b653ef73Array]

编译VSFTPD
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# tar zxvf vsftpd-1.2.0.tar.gz
&#Array1;root@Linux_win vsftpd&#Array3;# cd vsftpd-1.2.0
&#Array1;root@Linux_win vsftpd&#Array3;# make [/code:1:6b653ef73Array]

安装编译好的VSFTPD

执行“make,make install”将编译好的二进制文件、手册等复制到相应目录。可能需要手动执行以下复制:
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# cp vsftpd /usr/local/sbin/vsftpd
&#Array1;root@Linux_win vsftpd&#Array3;# cp vsftpd.conf.5 /usr/local/share/man/man5
&#Array1;root@Linux_win vsftpd&#Array3;# cp vsftpd.8 /usr/local/share/man/man8
[/code:1:6b653ef73Array]
如果不存在man5和man8目录,要先建立这两个目录
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;#mkdir /usr/local/share/man/man5
&#Array1;root@Linux_win vsftpd&#Array3;#mkdir /usr/local/share/man/man8
[/code:1:6b653ef73Array]
make不会自己copy配置文件,如果make install有错,则必须手工更改
[root@hpe45 vsftpd-1.2.0]# cp vsftpd.conf /etc

为本地用户设置PAM
如果允许本地用户登录VSFTPD,执行以下操作:
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# cp RedHat/vsftpd.pam /etc/pam.d/vsftpd [/code:1:6b653ef73Array]

3、pam_mysql安装
如果使用mysql的二进制包,那么必须加个开始包,且要修改Makefile文件,指定mysql的lib位置。
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# tar xvzf pam_mysql-0.5.tar.gz
&#Array1;root@Linux_win vsftpd&#Array3;# cd pam_mysql
&#Array1;root@Linux_win vsftpd&#Array3;# make
&#Array1;root@Linux_win vsftpd&#Array3;# cp pam_mysql.so /lib/security[/code:1:6b653ef73Array]

4、mysql安装。请查看其它文档



[color=red:6b653ef73Array][b:6b653ef73Array]vsftpd启动篇[/b:6b653ef73Array][/size:6b653ef73Array][/color:6b653ef73Array]

vsftpd 有两种运行方式,一种是standalone 一种是 via an inetd (或者 inetd or xinetd).
1、如何启动
1)系统自带的
[code:1:6b653ef73Array]&#Array1;root@Linux_win software&#Array3;# service vsftpd restart[/code:1:6b653ef73Array]
2)源包安装:
[root@Linux_win software]# /安装路径/vsftpd &

[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# /sbin/service xinetd restart  
或 
&#Array1;root@Linux_win vsftpd&#Array3;# /usr/local/sbin/vsftpd & [/code:1:6b653ef73Array]

2、standlone启动
具体的运行方式由参数listen决定。当listen参数值为YES时,VSFTPD单独运行,我们可以使用脚本/etc/rc.d/init.d/vsftpd来启动、关闭以及重启VSFTPD。命令如下:
  [code:1:6b653ef73Array]/etc/rc.d/init.d/vsftpd start|stop|restart [/code:1:6b653ef73Array]

3、xinetd启动,首先要将vsftpd.conf配置文件中的listen参数值改为NO。
其次,生成一个/etc/xinetd.d/vsftpd文件

[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;#vi /etc/vsftpd/vsftpd.conf或vi /etc/vsftp.conf
listen=NO [/code:1:6b653ef73Array]

[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;vi /etc/xinetd.d/vsftpd
内容如下:
service vsftpd
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/sbin/vsftpd
port = 21
log_on_success += PID HOST DURATION
log_on_failure += HOST
} [/code:1:6b653ef73Array]

通过修改disable值为no或yes,并重新启动xinetd,从而启动或停止VSFTPD。



[color=red:6b653ef73Array][b:6b653ef73Array]配置安全匿名服务器[/b:6b653ef73Array][/size:6b653ef73Array][/color:6b653ef73Array]

所要做的就是用vi修改vsftpd.conf文件

[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;#vi /etc/vsftpd.conf或/etc/vsftpd/vsftpd.conf[/code:1:6b653ef73Array]
修改后的vsftpd.conf文件看附件:

[quote:6b653ef73Array]#使用单独模式,并指定监听的IP地址
listen_address=ip address

#只允许匿名访问,不允许本地用户访问
anonymous_enable=YES
local_enable=NO

#取消写权限
write_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO

#启用详细的日志记录格式,设定记录传输日志的文件名。默认值为/var/log/vsftpd.log。
xferlog_enable=YES
xferlog_file=/var/log/vsftp.log

#对连接进行控制,还有超时时间,那就根据具体情况再说了。
connect_from_port_20=YES
pasv_min_port=50000
pasv_max_port=60000

#控制FTP最大并发数,限定每个IP地址的并发数。
max_clients=numerical value
max_per_ip=numerical value

#限定下载速度
anon_max_rate=80000


#使用ftpd_banner取代VSFTPD默认的欢迎词,免得泄漏相关信息
ftpd_banner=Welcome to this FTP Server

#只让匿名用户浏览可阅读的文件,不可以浏览整个系统
anon_world_readable_only=YES

#隐藏文件的所有者和组信息,匿名用户看到的文件的所有者和组全变为ftp
hide_ids=YES [/quote:6b653ef73Array]

[code:1:6b653ef73Array]附:vsftpd.conf
&#Array1;root@Linux_win vsftpd&#Array3;# cat vsftpd.conf
listen=YES
listen_address=1Array2.168.1.2

anonymous_enable=YES
local_enable=NO

write_enable=NO
anon_root=/home
anon_upload_enable=NO
anon_other_write_enable=NO
anon_mkdir_write_enable=NO
anon_world_readable_only=YES

#dirmessage_enable=YES
ftpd_banner=welcome to this FTP server

xferlog_enable=YES
#xferlog_file=/var/log/vsftpd.log

connect_from_port_20=YES
#pasv_mix_port=50000
#pasv_max_port=60000
#xferlog_std_format=YES

max_clients=10
max_per_ip=10

hide_ids=YES

#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd/chroot_list
#chroot_local_user=NO
#pam_service_name=/etc/pam.d/vsftpd

#guest_enable=YES
#guest_username=vsftpdvirtual
#virtual_use_local_privs=NO
#user_config_dir=/etc/vsftpd/vsftpd_user_conf[/code:1:6b653ef73Array]



[color=red:6b653ef73Array][b:6b653ef73Array]配置可上传匿名服务器[/b:6b653ef73Array][/size:6b653ef73Array][/color:6b653ef73Array]
[root@Linux_win vsftpd]#vi /etc/vsftpd/vsftpd.conf
修改文件,改后如下

[code:1:6b653ef73Array]&#Array1;root@Linux_win ftp&#Array3;# cat /etc/vsftpd/vsftpd.conf
listen=YES
listen_address=1Array2.168.1.2

anonymous_enable=YES
local_enable=NO

write_enable=YES
#anon_root=
anon_upload_enable=YES
anon_other_write_enable=YES
anon_mkdir_write_enable=YES
#anon_world_readable_only=YES


#dirmessage_enable=YES
ftpd_banner=welcome to this FTP server

xferlog_enable=YES
#xferlog_file=/var/log/vsftpd.log

connect_from_port_20=YES
#pasv_mix_port=50000
#pasv_max_port=60000
#xferlog_std_format=YES

max_clients=10
max_per_ip=10

hide_ids=YES

#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd/chroot_list
#chroot_local_user=NO
#pam_service_name=/etc/pam.d/vsftpd

#guest_enable=YES
#guest_username=vsftpdvirtual
#virtual_use_local_privs=NO
#user_config_dir=/etc/vsftpd/vsftpd_user_conf[/code:1:6b653ef73Array]

[code:1:6b653ef73Array]&#Array1;root@Linux_win ftp&#Array3;# mkidr /var/ftp/upload
&#Array1;root@Linux_win ftp&#Array3;# chmod o+w /var/ftp/upload[/code:1:6b653ef73Array]

anon_root参数指定的目录或默认的/var/ftp主目录,ftp匿名用户不可有写权限,否则会出错。
办法是在/var/ftp下建立一个新目录,使得该目录对ftp匿名用户可写。才能上传。
或不用匿名上传,而使用本地用户或虚拟用户 。




[color=red:6b653ef73Array][b:6b653ef73Array]配置本地用户[/b:6b653ef73Array][/size:6b653ef73Array][/color:6b653ef73Array]
修改vsftpd.conf
[code:1:6b653ef73Array]
&#Array1;root@Linux_win vsftpd&#Array3;# cat /etc/vsftpd/vsftpd.conf
listen=YES
listen_address=1Array2.168.1.2

anonymous_enable=NO
local_enable=YES
#local_root=

write_enable=YES
#anon_root=
#anon_upload_enable=YES
#anon_other_write_enable=YES
#anon_mkdir_write_enable=YES
#anon_world_readable_only=YES
#anon_umask=777

#dirmessage_enable=YES
ftpd_banner=welcome to this FTP server

xferlog_enable=YES
#xferlog_file=/var/log/vsftpd.log

connect_from_port_20=YES
#pasv_mix_port=50000
#pasv_max_port=60000
#xferlog_std_format=YES

max_clients=10
max_per_ip=10

hide_ids=YES

#limit all users in it’s owner dir
#chroot_local_user=YES

#or limit some
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list

#use ownwer conf file
user_config_dir=/etc/vsftpd/vsftpd_user_conf

pam_service_name=/etc/pam.d/vsftpd

#guest_enable=YES
#guest_username=vsftpdvirtual
#virtual_use_local_privs=NO[/code:1:6b653ef73Array]

由于上面了用户列表,因此须建立chroot_list文件,
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# touch /etc/vsftpd/chroot_list[/code:1:6b653ef73Array]
并加入以下内容,查看chroot_list文件内容,结果如下
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# cat /etc/vsftpd/chroot_list
sam
gem[/code:1:6b653ef73Array]
配置文件中指定了用户配置文件,因此建立此文件
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# mkdir /etc/vsftpd/vsftpd_user_conf[/code:1:6b653ef73Array]
并根据用户名建立文件
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# touch sam
&#Array1;root@Linux_win vsftpd&#Array3;# touch gem
&#Array1;root@Linux_win vsftpd&#Array3;# ls -l /etc/vsftpd/vsftpd_user_conf
总用量 8
-rw-r--r-- 1 root root 21 1月 8 00:25 sam
-rw-r--r-- 1 root root 25 1月 8 00:17 gem[/code:1:6b653ef73Array]

并在sam,gem文件加加入以下内容,可用vi编辑并保存,下面的虚拟用户也一样,不过只须更改文件内容就可以了
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# cat /etc/vsftpd/vsftpd_user_conf/sam
local_root=/home/sam[/code:1:6b653ef73Array]
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# cat /etc/vsftpd/vsftpd_user_conf/gem
local_root=/home/gem[/code:1:6b653ef73Array]


本地用户验证要用pam文件,内容是默认的。
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# cat /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[/code:1:6b653ef73Array]




[color=red:6b653ef73Array][b:6b653ef73Array]配置虚拟用户(mysql)[/b:6b653ef73Array][/color:6b653ef73Array][/size:6b653ef73Array]

  VSFTPD的本地用户本身是系统的用户,除了可以登录FTP服务器外,还可以登录系统使用其他系统资源,而

VSFTPD的虚拟用户则是FTP服务的专用用户,虚拟用户只能访问FTP服务器资源。对于只需要通过FTP对系统有读

写权限,而不需要其他系统资源的用户或情况来说,采用虚拟用户方式是很适合的。

  VSFTPD的虚拟用户采用单独的用户名/口令保存方式,与系统账号(passwd/shadow)分离,这大大增强了

系统的安全性。VSFTPD可以采用数据库文件来保存用户/口令,如hash;也可以将用户/口令保存在数据库服务器

中,如MySQL等。VSFTPD验证虚拟用户,则采用PAM方式。由于虚拟用户的用户名/口令被单独保存,因此在验证

时,VSFTPD需要用一个系统用户的身份来读取数据库文件或数据库服务器以完成验证,这就是guest用户,这正

如同匿名用户也需要有一个系统用户ftp一样。当然,guest用户也可以被认为是用于映射虚拟用户。

  配置虚拟用户分为几部分:guest用户的创建、用户/口令的保存、PAM认证配置、vsftpd.conf文件设置等

。在后面的例子中,假定存在虚拟用户win和wingger.



1、在系统中添加vsftpdvirtual用户,作为虚拟用户在系统中的代表。
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# useradd vsftpdvirtual [/code:1:6b653ef73Array]
  当虚拟用户登录后,所在的位置为vsftpdvirtual的自家目录/home/vsftpdvirtual。

2、配置文件vsftpd.conf: 加入以下内容
guest_enable=YES
guest_username=vsftpdvirtual
virtual_use_local_privs=YES|NO

3、虚拟用户的权限配置。
virtual_use_local_privs参数,
当该参数激活(YES)时,虚拟用户使用与本地用户相同的权限。所有虚拟用户的权限使用local参数。
当此参数关闭(NO)时,虚拟用户使用与匿名用户相同的权限,所有虚拟用户的权限使用anon参数。
这两者种做法相比,后者更加严格一些,特别是在有写访问的情形下。默认情况下此参数是关闭的(NO)。

由于本人的vsftpd为1.1.3,只好用virtual_use_local_privs=NO了:
因此匿名用户的设置即是虚拟用户的设置,在改参数权限时,同时也要修改目录权限
如:让用户不能浏览目录,但仍可以对文件操作且虚拟用户目录的权限改为只能由vsftpdvirtual操作:

[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# chown vsftpdvirtual.vsftpdvirtual /home/vsftpdvirtual
&#Array1;root@Linux_win vsftpd&#Array3;# chmod 700 /home/vsftpdvirtual [/code:1:6b653ef73Array]
由于这些设置对匿名用户生效。最好是禁止匿名用户登录。


在VSFTPD-1.2.0以上版本,当virtual_use_local_privs=YES时,只需write_enable=YES,虚拟用户就可以就拥

有写权限。应该与本地用户使用相同,有兴趣的可以去验证。

如果不同用户使用不同的目录,须加入权限
[code:1:6b653ef73Array]chown vsftpdvirtual.vsftpdvirtual /home/win
chown vsftpdvirtual.vsftpdvirtual /home/wingger[/code:1:6b653ef73Array]

4、用MySQL保存虚拟用户

  1、虚拟用户的用户名/口令的保存。这部分在MySQL数据库中完成。
首先,创建数据库vsftpdvirtual以及表users,并插入虚拟用户win、wingger。执行以下命令:
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# #mysql -uroot -p
mysql>create database vsftpdvirtual;
mysql>use vsftpdvirtual;
mysql>create table users(name char(16) binary,passwd char(16) binary);
mysql>insert into users (name,passwd) values (’win’,password(’123456’));
mysql>insert into users (name,passwd) values (’wingger’,password(’123456’));
mysql>quit [/code:1:6b653ef73Array]

然后,授权vsftpdvirtual只能读vsftpdvirtual数据库的users表。执行以下命令:
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# mysql -u root mysql -p
mysql>grant select on vsftpdvirtual.users to vsftpdvirtual@localhost identified by ’123456’;
mysql>quit [/code:1:6b653ef73Array]

验证刚才的操作是否成功可以执行下面命令:
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# mysql -u vsftpdvirtual -p123456 ftpdvirtual
mysql>select * from users; [/code:1:6b653ef73Array]
如果成功,将会列出wing、wingger和加密后的密码。
如下所示:
[quote:6b653ef73Array]mysql> select * from users;
+---------+------------------+
| name | passwd |
+---------+------------------+
| win | 23Array32fe477657768 |
| wingger | 23Array32fe477657768 |
+---------+------------------+
2 rows in set (0.00 sec)[/quote:6b653ef73Array]


  2、设置PAM认证。这里我们要用到一个利用mysql进行pam验证的开源项目(http://sourceforge.net/proj

ects/pam-mysql/)。首先从网站下载它的程序包pam_myql-0.5.tar.gz。在编译安装之前,要确保mysql-devel

的RPM包已经安装在你的机器上,如果没有请从RHL安装光盘中安装该包。然后,执行以下命令:
[code:1:6b653ef73Array]&#Array1;root@Linux_win vsftpd&#Array3;# tar xvzf pam_mysql-0.5.tar.gz
&#Array1;root@Linux_win vsftpd&#Array3;# cd pam_mysql
&#Array1;root@Linux_win vsftpd&#Array3;# make
&#Array1;root@Linux_win vsftpd&#Array3;# cp pam_mysql.so /bli/security
[/code:1:6b653ef73Array]

接下来,我们要设置vsftpd的PAM验证文件。打开/etc/pam.d/vsftpd文件,加入以下内容:
[quote:6b653ef73Array]  auth required pam_mysql.so user=vsftpdvirtual passwd=123456 host=localhost db=vsftpdvirtual

table=users usercolumn=name passwdcolumn=passwd crypt=2
  account required pam_mysql.so user=vsftpdvirtual passwd=123456 host=localhost

db=vsftpdvirtual table=users usercolumn=name passwdcolumn=passwd crypt=2 [/quote:6b653ef73Array]

具体可查看vsftpd源包里的EXAMPLE中的例子。



附:虚拟用户文档
1、vsftpd.conf配置文件
[code:1:6b653ef73Array]
&#Array1;root@Linux_win vsftpd&#Array3;# cat vsftpd.conf
listen=YES
listen_address=1Array2.168.1.2

anonymous_enable=NO
local_enable=YES

write_enable=YES
#anon_root=
anon_upload_enable=YES
anon_other_write_enable=YES
anon_mkdir_write_enable=YES
#anon_world_readable_only=YES
#anon_umask=777

#dirmessage_enable=YES
ftpd_banner=welcome to this FTP server

xferlog_enable=YES
#xferlog_file=/var/log/vsftpd.log

connect_from_port_20=YES
#pasv_mix_port=50000
#pasv_max_port=60000
#xferlog_std_format=YES

max_clients=10
max_per_ip=10

hide_ids=YES

#limit all users in it’s owner dir
#chroot_local_user=YES

#or limit some
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list

#use ownwer conf file
user_config_dir=/etc/vsftpd/vsftpd_user_conf

pam_service_name=/etc/pam.d/vsftpd

guest_enable=YES
guest_username=vsftpdvirtual
#virtual_use_local_privs=NO[/code:1:6b653ef73Array]


[code:1:6b653ef73Array]2、&#Array1;root@Linux_win vsftpd&#Array3;# cat /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.so user=vsftpdvirtual passwd=123456

host=localhost db=vsftpdvirtual table=users usercolumn=name passwdcolumn=passwd crypt=2
account required /lib/security/pam_mysql.so user=vsftpdvirtual passwd=123456

host=localhost db=vsftpdvirtual table=users usercolumn=name passwdcolumn=passwd crypt=2[/code:1:6b653ef73Array]

[code:1:6b653ef73Array]3、&#Array1;root@Linux_win vsftpd&#Array3;# cat /etc/vsftpd/chroot_list
win
wingger[/code:1:6b653ef73Array]

[code:1:6b653ef73Array]4、&#Array1;root@Linux_win vsftpd&#Array3;# ls -l /etc/vsftpd/vsftpd_user_conf
总用量 8
-rw-r--r-- 1 root root 21 1月 8 00:25 win
-rw-r--r-- 1 root root 25 1月 8 00:17 wingger[/code:1:6b653ef73Array]

[code:1:6b653ef73Array]5、&#Array1;root@Linux_win vsftpd&#Array3;# cat /etc/vsftpd/vsftpd_user_conf/win
local_root=/home/win
&#Array1;root@Linux_win vsftpd&#Array3;# cat /etc/vsftpd/vsftpd_user_conf/wingger
local_root=/home/wingger[/code:1:6b653ef73Array]

[code:1:6b653ef73Array]6、drwx------ 6 vsftpdvirtual vsftpdvirtual 40Array6 1月 8 00:16 vsftpdvirtual
drwxrwxrwx 5 vsftpdvirtual vsftpdvirtual 40Array6 1月 8 01:47 win
drwxrwxrwx 3 vsftpdvirtual vsftpdvirtual 40Array6 1月 8 20:1Array wingger[/code:1:6b653ef73Array]

7、版本:(vsFTPd 1.1.3)、pam_mysql-0.5.tar.gz、mysql3.23.54

8、[root@Linux_win vsftpd]# mysql -u vsftpdvirtual -pchenwy vsftpdvirtual

mysql> select * from users;
+---------+------------------+
| name | passwd |
+---------+------------------+
| win | 23Array32fe477657768 |
| wingger | 23Array32fe477657768 |
+---------+------------------+
2 rows in set (0.00 sec)

好好先生 回复于:2005-01-18 17:4Array:27
先保留,抽个时间做一下……,谢谢wingger MM带来的好贴子

wingger 回复于:2005-01-18 1Array:11:36
转:
[b:73aArray0b81a5]VSFTPD的设置选项 [/b:73aArray0b81a5]

  VSFTPD的配置文件/etc/vsftpd/vsftpd.conf是个文本文件。以“#”字符开始的行是注释行。每个选项设置为一行,格式为“option=value”,注意“=”号两边不能留空白符。除了这个主配置文件外,还可以给特定用户设定个人配置文件,具体介绍见后。
  VSFTPD包中所带的vsftpd.conf文件配置比较简单,而且非常偏执狂的(文档自称:-))。我们可以根据实际情况对其进行一些设置,以使得VSFTPD更加可用。



[b:73aArray0b81a5]1、连接选项 [/b:73aArray0b81a5]

  本部分主要是一些与建立FTP链接相关的选项。

1.1、监听地址与控制端口

  listen_address=ip address
  此参数在VSFTPD使用单独(standalone)模式下有效。此参数定义了在主机的哪个IP地址上监听FTP请求,即在哪个IP地址上提供FTP服务。对于只有一个IP地址的主机,不需要使用此参数。对于多址主机,不设置此参数,则监听所有IP地址。默认值为无。

  listen_port=port_value
  指定FTP服务器监听的端口号(控制端口),默认值为21。此选项在standalone模式下生效。

1.2、FTP模式与数据端口

  FTP 分为两类,PORT FTP和PASV FTP,PORT FTP是一般形式的FTP。这两种FTP在建立控制连接时操作是一样的,都是由客户端首先和FTP服务器的控制端口(默认值为21)建立控制链接,并通过此链接进行传输操作指令。它们的区别在于使用数据传输端口(ftp-data)的方式。PORT FTP由FTP服务器指定数据传输所使用的端口,默认值为20。PASV FTP由FTP客户端决定数据传输的端口。PASV FTP这种做法,主要是考虑到存在防火墙的环境下,由客户端与服务器进行沟通(客户端向服务器发出数据传输请求中包含了数据传输端口),决定两者之间的数据传输端口更为方便一些。

  port_enable=YES|NO
  如果你要在数据连接时取消PORT模式时,设此选项为NO。默认值为YES。

  connetc_from_port_20=YES|NO
  控制以PORT模式进行数据传输时是否使用20端口(ftp-data)。YES使用,NO不使用。默认值为NO,但RHL自带的vsftpd.conf文件中此参数设为YES。

  ftp_data_port=port number
  设定ftp数据传输端口(ftp-data)值。默认值为20。此参数用于PORT FTP模式。

  port_promiscuous=YES|NO
  默认值为NO。为YES时,取消PORT安全检查。该检查确保外出的数据只能连接到客户端上。小心打开此选项。

  pasv_enable=YES|NO
  YES,允许数据传输时使用PASV模式。NO,不允许使用PASV模式。默认值为YES。

  pasv_min_port=port number
  pasv_max_port=port number
  设定在PASV模式下,建立数据传输所可以使用port范围的下界和上界,0 表示任意。默认值为0。把端口范围设在比较高的一段范围内,比如50000-60000,将有助于安全性的提高。

  pasv_promiscuous=YES|NO
  此选项激活时,将关闭PASV模式的安全检查。该检查确保数据连接和控制连接是来自同一个IP地址。小心打开此选项。此选项唯一合理的用法是存在于由安全隧道方案构成的组织中。默认值为NO。

  pasv_address=
  此选项为一个数字IP地址,作为PASV命令的响应。默认值为none,即地址是从呼入的连接套接字(incoming connectd socket)中获取。

1.3 ASCII模式

  默认情况下,VSFTPD是禁止使用ASCII传输模式。即使FTP客户端使用asc命令,指明要使用ASCII模式,但是,VSFTPD表面上接受了asc命令,而在实际传输文件时,还是使用二进制方式。下面选项控制VSFTPD是否使用ASCII传输模式。

  ascii_upload_enable=YES|NO
  控制是否允许使用ascii模式上传文件,YES允许,NO不允许,默认为NO。

  ascii_download_enable=YES|NO
  控制是否允许使用ascii模式下载文件,YES允许,NO不允许,默认为NO。



[b:73aArray0b81a5]2、性能与负载控制 [/b:73aArray0b81a5]

2.1、超时选项

  idle_session_timeout=
  空闲(发呆)用户会话的超时时间,若是超出这时间没有数据的传送或是指令的输入,则会强迫断线。单位为秒,默认值为300。

  data_connection_timeout=
  空闲的数据连接的超时时间。默认值为300 秒。

  accept_timeout=numerical value
  接受建立联机的超时设定,单位为秒。默认值为60。

  connect_timeout=numerical value
  响应PORT方式的数据联机的超时设定,单位为秒。默认值为60。以上两个选项针对客户端的,将使客户端空闲1分钟后自动中断连接,并在中断1分钟后自动激活连接。

2.2 负载控制

  max_clients=numerical value
  此参数在VSFTPD使用单独(standalone)模式下有效。此参数定义了FTP服务器最大的并发连接数,当超过此连接数时,服务器拒绝客户端连接。默认值为0,表示不限最大连接数。
?
  max_per_ip=numerical value
  此参数在VSFTPD使用单独(standalone)模式下有效。此参数定义每个IP地址最大的并发连接数目。超过这个数目将会拒绝连接。此选项的设置将影响到象网际快车这类的多进程下载软件。默认值为0,表示不限制。

  anon_max_rate=value
  设定匿名用户的最大数据传输速度value,以Bytes/s为单位。默认无。

  local_max_rate=value
  设定用户的最大数据传输速度value,以Bytes/s为单位。默认无。此选项对所有的用户都生效。此外,也可以在用户个人配置文件中使用此选项,以指定特定用户可获得的最大数据传输速率。
  步骤如下:
  ①在vsftpd.conf中指定用户个人配置文件所在的目录,如:
  user_config_dir=/etc/vsftpd/userconf
  ②生成/etc/vsftpd/userconf目录。
  ③用户个人配置文件是在该目录下,与特定用户同名的文件,如:
  /etc/vsftpd/userconf/xiaowang
  ④在用户的个人配置文件中设置local_max_rate参数,如:
  local_max_rate=80000
  以上步骤设定FTP用户xiaowang的最大数据传输速度为80KBytes/s。

  VSFTPD 对于速度控制的变化范围大概在80%到120%之间。比如我们限制最高速度为100KBytes/s, 但实际的速度可能在80KBytes/s 到120KBytes/s 之间。当然,若是线路带宽不足时,速率自然会低于此限制。




[b:73aArray0b81a5]3 用户选项[/b:73aArray0b81a5]

  VSFTPD的用户分为三类:匿名用户、本地用户(local user)以及虚拟用户(guest)。

3.1、匿名用户

  anonymous_enable=YES|NO
  控制是否允许匿名用户登录,YES允许,NO不允许,默认值为YES。

  ftp_username=
  匿名用户所使用的系统用户名。默认下,此参数在配置文件中不出现,值为ftp。

  no_anon_password=YES|NO
  控制匿名用户登入时是否需要密码,YES不需要,NO需要。默认值为NO。
  
  deny_email_enable=YES|NO
  此参数默认值为NO。当值为YES时,拒绝使用banned_email_file参数指定文件中所列出的e-mail地址进行登录的匿名用户。即,当匿名用户使用banned_email_file文件中所列出的e-mail进行登录时,被拒绝。显然,这对于阻击某些Dos攻击有效。当此参数生效时,需追加banned_email_file参数

  banned_email_file=/etc/vsftpd.banned_emails
  指定包含被拒绝的e-mail地址的文件,默认文件为/etc/vsftpd.banned_emails。

  anon_root=
  设定匿名用户的根目录,即匿名用户登入后,被定位到此目录下。主配置文件中默认无此项,默认值为/var/ftp/。

  anon_world_readable_only=YES|NO
  控制是否只允许匿名用户下载可阅读文档。YES,只允许匿名用户下载可阅读的文件。NO,允许匿名用户浏览整个服务器的文件系统。默认值为YES。

  anon_upload_enable=YES|NO
  控制是否允许匿名用户上传文件,YES允许,NO不允许,默认是不设值,即为NO。除了这个参数外,匿名用户要能上传文件,还需要两个条件:一,write_enable参数为YES;二,在文件系统上,FTP匿名用户对某个目录有写权限。

  anon_mkdir_write_enable=YES|NO
  控制是否允许匿名用户创建新目录,YES允许,NO不允许,默认是不设值,即为NO。当然在文件系统上,FTP匿名用户必需对新目录的上层目录拥有写权限。

  anon_other_write_enable=YES|NO
  控制匿名用户是否拥有除了上传和新建目录之外的其他权限,如删除、更名等。YES拥有,NO不拥有,默认值为NO。

  chown_uploads=YES|NO
  是否修改匿名用户所上传文件的所有权。YES,匿名用户所上传的文件的所有权将改为另外一个不同的用户所有,用户由chown_username参数指定。此选项默认值为NO。

  chown_username=whoever
  指定拥有匿名用户上传文件所有权的用户。此参数与chown_uploads联用。不推荐使用root用户。



3.2、本地用户

  在使用FTP服务的用户中,除了匿名用户外,还有一类在FTP服务器所属主机上拥有账号的用户。VSFTPD中称此类用户为本地用户(local users),等同于其他FTP服务器中的real用户。

  local_enable=YES|NO
  控制vsftpd所在的系统的用户是否可以登录vsftpd。默认值为YES。

  local_root=
  定义所有本地用户的根目录。当本地用户登入时,将被更换到此目录下。默认值为无。

  user_config_dir=
  定义用户个人配置文件所在的目录。用户的个人配置文件为该目录下的同名文件。个人配置文件的格式与vsftpd.conf格式相同。例如定义 user_config_dir=/etc/vsftpd/userconf,并且主机上有用户xiaowang,lisi,那我们可以在 user_config_dir的目录新增名为xiaowang、lisi的两个文件。当用户lisi 登入时,VSFTPD则会读取user_config_dir下lisi这个文件中的设定值,应用于用户lisi。默认值为无。

3.3、虚拟用户

  guest_enable=YES|NO
  若是启动这项功能,所有的非匿名登入者都视为guest。默认值为关闭。

  guest_username=
  定义VSFTPD的guest用户在系统中的用户名。默认值为ftp。




[b:73aArray0b81a5]4、安全措施 [/b:73aArray0b81a5]

4.1、用户登录控制

  pam_service_name=vsftpd
  指出VSFTPD进行PAM认证时所使用的PAM配置文件名,默认值是vsftpd,默认PAM配置文件是/etc/pam.d/vsftpd。

  /etc/vsftpd.ftpusers
  VSFTPD禁止列在此文件中的用户登录FTP服务器。这个机制是在/etc/pam.d/vsftpd中默认设置的。

  userlist_enable=YES|NO
  此选项被激活后,VSFTPD将读取userlist_file参数所指定的文件中的用户列表。当列表中的用户登录FTP服务器时,该用户在提示输入密码之前就被禁止了。即该用户名输入后,VSFTPD查到该用户名在列表,VSFTPD就直接禁止掉该用户,不会再进行询问密码等后续步聚。默认值为NO。

  userlist_file=/etc/vsftpd.user_list
  指出userlist_enable选项生效后,被读取的包含用户列表的文件。默认值是/etc/vsftpd.user_list。

  userlist_deny=YES|NO
  决定禁止还是只允许由userlist_file指定文件中的用户登录FTP服务器。此选项在userlist_enable 选项启动后才生效。YES,默认值,禁止文件中的用户登录,同时也不向这些用户发出输入口令的提示。NO,只允许在文件中的用户登录FTP服务器。
  
  tcp_wrappers=YES|NO
  在VSFTPD中使用TCP_Wrappers远程访问控制机制,默认值为YES。

4.2、目录访问控制

  chroot_list_enable=YES|NO
  锁定某些用户在自家目录中。即当这些用户登录后,不可以转到系统的其他目录,只能在自家目录(及其子目录)下。具体的用户在chroot_list_file参数所指定的文件中列出。默认值为NO。

  chroot_list_file=/etc/vsftpd/chroot_list
  指出被锁定在自家目录中的用户的列表文件。文件格式为一行一用户。通常该文件是/etc/vsftpd/chroot_list。此选项默认不设置。

  chroot_local_users=YES|NO
  将本地用户锁定在自家目录中。当此项被激活时,chroot_list_enable和chroot_local_users参数的作用将发生变化,chroot_list_file所指定文件中的用户将不被锁定在自家目录。本参数被激活后,可能带来安全上的冲突,特别是当用户拥有上传、 shell访问等权限时。因此,只有在确实了解的情况下,才可以打开此参数。默认值为NO。

  passwd_chroot_enable
  当此选项激活时,与chroot_local_user选项配合,chroot()容器的位置可以在每个用户的基础上指定。每个用户的容器来源于/etc/passwd中每个用户的自家目录字段。默认值为NO。

4.3、文件操作控制

  hide_ids=YES|NO
  是否隐藏文件的所有者和组信息。YES,当用户使用"ls -al"之类的指令时,在目录列表中所有文件的拥有者和组信息都显示为ftp。默认值为NO。

  ls_recurse_enable=YES|NO
  YES,允许使用"ls -R" 指令。这个选项有一个小的安全风险,因为在一个大型FTP站点的根目录下使用"ls -R"会消耗大量系统资源。默认值为NO。

  write_enable=YES|NO
  控制是否允许使用任何可以修改文件系统的FTP 的指令,比如STOR、DELE、RNFR、RNTO、MKD、RMD、APPE 以及SITE。默认值为NO,不过自带的简单配置文件中打开了该选项。

  secure_chroot_dir=
  这选项指向一个空目录,并且ftp用户对此目录无写权限。当vsftpd不需要访问文件系统时,这个目录将被作为一个安全的容器,用户将被限制在此目录中。默认目录为/usr/share/empty。

4.4、新增文件权限设定

  anon_umask=
  匿名用户新增文件的umask 数值。默认值为077。

  file_open_mode=
  上传档案的权限,与chmod 所使用的数值相同。如果希望上传的文件可以执行,设此值为0777。默认值为0666。

  local_umask=
  本地用户新增档案时的umask 数值。默认值为077。不过,其他大多数的FTP服务器都是使用022。如果您的用户希望的话,可以修改为022。在自带的配置文件中此项就设为了022。




[b:73aArray0b81a5]5、提示信息 [/b:73aArray0b81a5]

  ftpd_banner=login banner string
  此参数定义了login banner string(登录欢迎语字符串)。用户可以自行修改。预设值为无。当ftpd_banner设置后,将取代系统原来的欢迎词。

  banner_file=/directory/vsftpd_banner_file
  此项指定一个文本文件,当使用者登入时,会显示此该文件的内容,通常为欢迎话语或是说明。默认值为无。与ftpd_banner相比, banner_file是文本文件的形式,而ftpd_banner是字串格式。banner_file选项将取代ftpd_banner选项。

  dirmessage_enable=YES|MO
  控制是否启用目录提示信息功能。YES启用,NO不启用,默认值为YES。此功能启用后,当用户进入某一个目录时,会检查该目录下是否有message_file选项所指定的文档,若是有,则会出现此文档的内容,通常这个档案会放置欢迎话语,或是对该目录的说明。

  message_file=
  此选项,仅在dirmessage_enable选项激活方生效。默认值为.message。




[b:73aArray0b81a5]6、日志设置[/b:73aArray0b81a5]

  xferlog_enable=YES|NO
  控制是否启用一个日志文件,用于详细记录上传和下载。该日志文件由xferlog_file选项指定。默认值为NO,但简单配置文件中激活此选项。

  xferlog_file=
  这个选项设定记录传输日志的文件名。默认值为/var/log/vsftpd.log。

  xferlog_std_format=YES|NO
  控制日志文件是否使用xferlog的标准格式,如同wu-ftpd一样。使用xferlog格式,可以重新使用已经存在的传输统计生成器。然而,默认的日志格式更为可读性。默认值为NO,但自带的配置文件中激活了此选项。

  log_ftp_protocol=YES|NO
  当此选项激活后,所有的FTP请求和响应都被记录到日志中。提供此选项时,xferlog_std_format不能被激活。这个选项有助于调试。默认值为NO。




[b:73aArray0b81a5]7、其他设置[/b:73aArray0b81a5]

  setproctitle_enable=YES|NO
  YES,VSFTPD将在系统进程列表中显示每个会话(session)的状态。也就是说,进程报告将显示每个vsftpd会话在做什么(挂起、下载等),如用ps -ef|grep ftp。出于安全的目的,可以考虑将此选项关闭。NO,进程报告只显示一个vsftpd进程在运行。默认值为NO。

  text_userdb_names=YES|No
  当使用者登入后使用ls -al 之类指令时,目录列表的用户和组信息域,默认是出现拥有者的UID,而不是该档案拥有者的名称。若是希望出现拥有者的名称,则将此功能开启。默认值为NO。

  user_localtime=YES|NO
  默认为NO。YES,VSFTPD显示目录列表时使用你本地时区的时间。默认是显示GMT时间。同样,由ftp命令“MDTM”返回的时间值也受此选项影响。

  check_shell=YES|NO
  此选项仅对不使用PAM方式的VSFTPD生效。当此选项关闭后,当本地用户登录时,VSFTPD不会检查/etc/shells文件以寻找一个有效的用户shell。默认为YES。

  nopriv_user=
  指定一个用户,当VSFTPD不想要什么权限时,使用此用户身份。这用户最好是一个专用的用户,而不是用户nobody。在大多数的机器上,nobody用户被用于大量重要的事情。默认值为nobody。

  pam_service_name=
  指明VSFTPD使用用PAM验证服务时的PAM配置文件名。默认值为ftp。

linsanpi 回复于:2005-01-1Array 02:1Array:36
不过还有一个问题,请高手帮帮忙:
有一台代理服务器,用linuxArray.0做的iptables+NAT(比如外网地址为218.132.Array4.245,内网网卡地址为1Array2.168.0.1)

其他机器设置了网关为1Array2.168.0.1,设置了DNS后,全可以正常上网。

现在在内网用(1Array2.168.0.251)LinuxArray.0建立了一台电影服务器用Samba给内网用户共享,现在其他全成功了,但想在这台电影服务器上建立vsftp以便在外网连接上传,下载电影,但ftp只能在内网通过1Array2.168.0.251访问,怎样在外网也能连接到这台机器的FTP?

(唉!嘴太笨,不知大家能明白不?)高手帮帮忙啊!!谢了!!

linsanpi 回复于:2005-01-1Array 02:26:24
是要建立端口映射吧?但是怎样建立?是在代理服务器上建立还是在1Array2.168.0.251这台做vsftp的机器上建立呢?

具体怎么操作呢?

小弟是菜鸟,请各位一定帮帮忙啊,我真的很急啊!谢谢你们

wingger 回复于:2005-01-1Array 08:43:57
在代理上做NAT

Intranet 回复于:2005-01-20 08:56:43
??``板zhu````


收下了`` :mrgreen:

eagerlinuxer 回复于:2005-01-20 10:03:27
很全,收了 :)

johnzw 回复于:2005-01-20 11:03:37
[quote:8edb528fba="linsanpi"]不过还有一个问题,请高手帮帮忙:
有一台代理服务器,用linuxArray.0做的iptables+NAT(比如外网地址为218.132.Array4.245,内网网卡地址为1Array2.168.0.1)

其他机器设置了网关为1Array2.168.0.1,设置了DNS后,全可以正常?.........[/quote:8edb528fba]

iptables ?t nat ?A PREROUTING ?d 218.132.Array4.245 -p tcp --dport 21?j DNAT --to-destination 1Array2.168.0.251
但是这时你不能从内网来访问218.132.Array4.245的21端口,如果要做的话
iptables ?t nat ?A POSTROUTING ?d 218.132.Array4.245 -p tcp --dport 21 ?j SNAT ?to-source 1Array2.168.0.251


以上的设置仅是针对内网服务器端口映射到外网,你还要在iptables的FORWARD链里添加一条针对ftp的状态检测规则.
iptables -A FORWARD ?i eth0 ?o eth1 ?p tcp --dport 21 -m state --state NEW,ESTABLISHED?j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
如果有什么错误的话,到网上去找找相关资料吧.

kelonglong 回复于:2005-01-21 08:3Array:16
真的是很不错的帖子呀!~~~

eagerlinuxer 回复于:2005-01-21 11:57:2Array
按上面的方法,配置vsftpd2.0.1+mysql3.2+pam_mysql0.5,但认证总是不能通过,提示如下错误:

530 Login incorrect.
Login failed.

看CU上相关的贴子,也有人碰到的相同的问题,但没有明确的解决方法,还请高手指点一二。

/var/log/messages中的错误信息:
Jan 21 11:43:35 test-ftp vsftpd: Fri Jan 21 11:43:35 2005 [pid 1Array726] [larry] FAIL LOGIN: Client "1Array2.168.13.101"

我的vsftpd.conf文件:
listen=YES

# Access rights
anonymous_enable=NO
local_enable=YES
guest_enable=YES
guest_username=vsftpdvirtual
virtual_use_local_privs=YES
write_enable=YES
#anon_upload_enable=NO
#anon_mkdir_write_enable=NO
#anon_other_write_enable=NO

# Security
pam_service_name=/etc/pam.d/vsftpd
anon_world_readable_only=YES
connect_from_port_20=YES
hide_ids=YES
port_enable=YES
pasv_min_port=50000
pasv_max_port=60000
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
#ssl_enable=YES
#allow_anon_ssl=YES

# Features
syslog_enable=YES
#xferlog_enable=YES
xferlog_std_format=YES
xferlog_file=/var/log/vsftpd.log
#vsftpd_log_file=/home/log/vsftpd.log
ls_recurse_enable=NO
ascii_download_enable=NO
async_abor_enable=YES

# Performance
#one_process_model=YES
idle_session_timeout=120
data_connection_timeout=300
accept_timeout=60
connect_timeout=60
anon_max_rate=30000
max_clients=700
max_per_ip=2

#Use ownwer conf file
user_config_dir=/etc/vsftpd/vsftpd_user_conf

请多帮忙。

wingger 回复于:2005-01-21 12:25:08
pam_service_name=/etc/pam.d/vsftpd
chroot_list_file=/etc/vsftpd.chroot_list
user_config_dir=/etc/vsftpd/vsftpd_user_conf
这三处的内容贴出来看看

eagerlinuxer 回复于:2005-01-21 14:1Array:5Array
[root@test-ftp root]# cat /etc/pam.d/vsftpd
#%PAM-1.0
auth required pam_mysql.so user=vsftpdvirtual passwd=123456 host=localhost db=vsftpdvirtual table=users usercolumn=name passwdcolumn=passwd crypt=2
account required pam_mysql.so user=vsftpdvirtual passwd=123456 host=localhost db=vsftpdvirtual table=users usercolumn=name passwdcolumn=passwd crypt=2

[root@test-ftp root]# cat /etc/vsftpd.chroot_list
wy
vsftpdvirtual


[root@test-ftp root]# ll /etc/vsftpd/vsftpd_user_conf
total 4
-rw-r--r-- 1 root root 1Array Jan 20 13:05 larry

[root@test-ftp root]# cat /etc/vsftpd/vsftpd_user_conf/larry
local_max_rate=800


[root@test-ftp root]# mysql -uvsftpdvirtual -p vsftpdvirtual
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25 to server version: 3.23.54

Type ’help;’ or ’\h’ for help. Type ’\c’ to clear the buffer.

mysql> select * from users;
+-------+------------------+
| name | passwd |
+-------+------------------+
| rick | 4efa423f631ddb53 |
| larry | 4448ddArraya3ArrayabArray7e1 |
+-------+------------------+
2 rows in set (0.00 sec)

wingger 回复于:2005-01-21 14:27:48
你的pam文件里的数据库密码和mysql里的不一样啊???那用户如何用pam中的密码登录验证呢?

cat /etc/vsftpd.chroot_list
wy
vsftpdvirtual
的允许帐号和数据库中的rick larry 不一样???

eagerlinuxer 回复于:2005-01-21 15:02:25
在 /etc/vsftpd.chroot_list 中加了 larry,重启vsftpd服务,还是不行
我想还是与pam有关,但不知是哪的毛病。
[root@test-ftp root]# ftp 1Array2.168.13.101
Connected to 1Array2.168.13.101.
220 (vsFTPd 2.0.1)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (1Array2.168.13.101:root): larry
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.

wingger 回复于:2005-01-21 15:27:43
#%PAM-1.0
auth required pam_mysql.so [color=red:f23efebdcc]user=vsftpdvirtual passwd=123456[/color:f23efebdcc] host=localhost db=vsftpdvirtual table=users usercolumn=name passwdcolumn=passwd crypt=2
account required pam_mysql.so [color=red:f23efebdcc] user=vsftpdvirtual passwd=123456[/color:f23efebdcc] host=localhost db=vsftpdvirtual table=users usercolumn=name passwdcolumn=passwd crypt=2

[root@test-ftp root]# mysql -uvsftpdvirtual -p vsftpdvirtual
你的mysql里的用户和帐号和pam的不一样

你的pam是[color=red:f23efebdcc]user=vsftpdvirtual passwd=123456[/color:f23efebdcc]
而mysql是[color=red:f23efebdcc]vsftpdvirtual vsftpdvirtual [/color:f23efebdcc]

eagerlinuxer 回复于:2005-01-21 17:27:12
没有啊,我的mysql帐号:vsftpdvirtual 密码:123456
请看:

[wy@test-ftp wy]$ mysql -uvsftpdvirtual -p123456 vsftpdvirtual
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 26 to server version: 3.23.54

Type ’help;’ or ’\h’ for help. Type ’\c’ to clear the buffer.

mysql> select * from users;
+-------+------------------+
| name | passwd |
+-------+------------------+
| rick | 4efa423f631ddb53 |
| larry | 4448ddArraya3ArrayabArray7e1 |
+-------+------------------+
2 rows in set (0.00 sec)

wingger 回复于:2005-01-22 10:46:15
不好意思,我文中有个地方写错了
pam_mysql.so应该是考到/lib/security下
你去/lib/security下看看是否有pam_myqsl.so这个文件

eagerlinuxer 回复于:2005-01-22 22:31:53
有这个文件,我考了。
[root@test-ftp root]# ll /lib/security/ | grep mysql
-rw-r--r-- 1 root root 1Array840 Jan 20 16:57 pam_mysql.o
-rwxr-xr-x 1 root root 25141 Jan 20 16:16 pam_mysql.so

wingger 回复于:2005-01-22 23:20:06
我现在用vsftp2.0.1+pam_mysql0.5+mysql-3.23.54a-11也成功了

你再检查一下

就是vsftpd.conf
/etc/pam.d/vsftpd
还有几个附属的配置文件,

[root@win wingger]# ftp localhost
Connected to localhost (1Array2.168.174.4).
220 (vsFTPd 2.0.1)
Name (localhost:root): wingger
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

eagerlinuxer 回复于:2005-01-23 01:0Array:17
唉,终于可以了,原因就是我偷了一个很小的懒,却浪费了两天时间:
错误:
pam_service_name=/etc/pam.d/vsftpd $
正确:
pam_service_name=/etc/pam.d/vsftpd$

这是我用 sed -n ’1,$l’ vsftpd.conf 命令看的vsftpd.conf文件中的一行,正确的那个行末直接是换行符,而错误的那个行末多了一个空格(当时偷了一个很小的懒,直接粘贴时多复制了一个空格)。
就是这样一个很小的差别,就会让mysql的pam认证不能通过。不信大家可以试试。真是冤!浪费了我好多时间。

allunix 回复于:2005-01-26 21:11:1Array
请教:
port ftp 是不是主动FTP?

pasv ftp 是不是被动FTP?

unix 系统默认安装出来的ftp是那种啊?

??????????????????
一点不懂,等高手指点。。。 :em02:

采风 回复于:2005-01-27 08:11:06
[quote:0bac7eArray021="allunix"]请教:
port ftp 是不是主动FTP?

pasv ftp 是不是被动FTP?

unix 系统默认安装出来的ftp是那种啊?

??????????????????
一点不懂,等高手指点。。。 :em02:[/quote:0bac7eArray021]



都支持 :roll:

yuyuyou 回复于:2005-04-08 02:56:00
wingger:你好!

我照做你的教程,出现下列错误,希望能得到你 的帮助!
[root@yuyuyouderedhat vsftpd_user_conf]# /opt/vsftpd/local/sbin/vsftpd &
[2] 2620
[root@yuyuyouderedhat vsftpd_user_conf]# 500 OOPS: unrecognised variable in config file
----------------------------------------------------
我把几个主要文件内容放上来了,我觉得不是vsftpd的问题,我配置匿名服务器成功启动了。

[root@yuyuyouderedhat vsftpd_user_conf]# cd /home
[root@yuyuyouderedhat home]# ls
vsftpdvirtual win wingger yuyu
[root@yuyuyouderedhat home]#cd /etc/vsftpd
[root@yuyuyouderedhat vsftpd]# ls
vsftpd.chroot_list vsftpd_user_conf
[root@yuyuyouderedhat vsftpd]cd vsftpd_user_conf
[root@yuyuyouderedhat vsftpd_user_conf]ls
[root@yuyuyouderedhat vsftpd_user_conf]# ls
win wingger
[root@yuyuyouderedhat vsftpd_user_conf]# cat win
local_root=/home/win
[root@yuyuyouderedhat vsftpd_user_conf]# cat wingger
local_root=/home/wingger
[root@yuyuyouderedhat vsftpd]# cat vsftpd.chroot_list
win
wingger
[root@yuyuyouderedhat vsftpd]# ls -ld *
-rw-r--r-- 1 root root 13 4ÔArray4; 8 0Array:14 vsftpd.chroot_list
drwxr-xr-x 2 root root 40Array6 4ÔArray4; 8 10:44 vsftpd_user_conf
[root@yuyuyouderedhat home]# ls -ld *
drwx------ 3 vsftpdvirtual vsftpdvirtual 40Array6 4ÔArray4; 5 08:45 vsftpdvirtual
drw------- 3 vsftpdvirtual vsftpdvirtual 40Array6 4ÔArray4; 8 0Array:21 win
drw------- 3 vsftpdvirtual vsftpdvirtual 40Array6 4ÔArray4; 8 0Array:21 wingger


--------------------------------------------------------
[root@yuyuyouderedhat home]# /opt/mysql/bin/mysql -u vsftpdvirtual -p123456 vsftpdvirtual
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.57-log

Type ’help;’ or ’\h’ for help. Type ’\c’ to clear the buffer.

mysql> select * from users;
+---------+------------------+
| name | passwd |
+---------+------------------+
| win | 5654Array1d704013245 |
| wingger | 5654Array1d704013245 |
+---------+------------------+
2 rows in set (0.24 sec)
---------------------------------------------------
[root@yuyuyouderedhat home]# vi /etc/vsftpd.conf
listen=YES

dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES

guest_enable=YES
guest_username=vsftpdvirtual

virtual_usr_local_privs=NO
anon_world_readable_only=NO
write_enable=YES
anon_upload_enable=YES
anon_other_write_enable=YES
anonymous_enable=NO

chroot_local_user=YES
chroot_list_enable=YES
chroot_list_enable=/etc/vsftpd/vsftpd.chroot_list

user_config_dir=/etc/vsftpd/vsftpd_user_conf
pam_service_name=/etc/pam.d/vsftpd

ftpd_banner=welcome to yuyu’ftp server!
-----------------------------------------------------
[root@yuyuyouderedhat home]# vi /etc/pam.d/vsftpd
#%PAM-1.0
#auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
#auth required /lib/security/pam_pwdb.so shadow nullok
#auth required /lib/security/pam_shells.so
#account required /lib/security/pam_pwdb.so
#session required /lib/security/pam_pwdb.so
auth required pam_mysql.so user=vsftpdvirtual passwd=123456 host=localhost db=vsftpdvirtual table=users usercolumn=name passwdcolumn=password crypt=2

account required pam_mysql.so user=vsftpdvirtual passwd=123456 host=localhost db=vsftpdvirtual table=users usercolumn=name passwdcolumn=password crypt=2
------------------------------------------------------

yuyuyou 回复于:2005-04-08 10:58:35
又检查了一遍vsftpd.conf:
-----------------------------
listen=YES
local_enable=YES
guest_enable=YES
guest_username=vsftpdvirtual
virtual_usr_local_privs=NO
anon_world_readable_only=NO
write_enable=YES
anon_upload_enable=YES
anon_other_write_enable=YES
anon_mkdir_write_enable=YES
anonymous_enable=NO
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_enable=/etc/vsftpd/vsftpd.chroot_list
user_config_dir=/etc/vsftpd/vsftpd_user_conf
pam_service_name=/etc/pam.d/vsftpd
ftpd_banner=welcome to yuyu’ftp server!
--------------------


但还是问题依旧!

[root@yuyuyouderedhat root]# /opt/vsftpd/local/sbin/vsftpd &
[1] 1Array86
500 OOPS: unrecognised variable in config file

wingger 回复于:2005-04-08 11:18:15
肯定是有语法错误啦,要不你一条一条的试吧

yuyuyou 回复于:2005-04-08 11:53:46
试了,,,问题依旧!


晕了,头大,,,,

yuyuyou 回复于:2005-04-08 12:08:53
UP

wingger 回复于:2005-04-08 12:18:31
一条一条的试啊,看哪一条有问题,注释掉

yuyuyou 回复于:2005-04-08 14:02:23
现在可以启动了!

是这句:

virtual_use_local_privs=NO

不管是YES还是NO,都会使vsftpd无法起动,注释掉后可以启动了,但是无法登陆FTP。


在IE里面用
ftp://1Array2.168.171.128
匿名无法登陆,这个应该是正常的;
用win和它的密码123456也无法登陆。

用LEADFTP连接,提示530错误,
530 login incorrect。

yuyuyou 回复于:2005-04-10 00:11:30
wingger:

你这步是怎么做的,能贴出代码吗?

[code:1:168cf51411]
安装前的条件:

进入vsftpd目录
编辑 "builddefs.h"文件,里面定义了pam功能,tcp_wrappers功能,ssl功能,根据需要定义pam或tcpwrapper功能,以消ssl功能 [/code:1:168cf51411]

yuyuyou 回复于:2005-04-14 16:15:48
再顶起
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#4

帖子 243750496 » 2013-07-11 14:27

show databases;//可以查看有哪些数据库,返回数据库名(databaseName)
2. DROP DATABASE 语句
删除数据库就像创建它一样容易,假如有权限,执行下列语句即可
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#5

帖子 243750496 » 2013-07-11 16:40

参照了这篇帖子http://forum.ubuntu.org.cn/viewtopic.php?f=54&t=368282也不行
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#6

帖子 oneleaf » 2013-07-11 17:50

你的认证都改为Mysql的虚拟用户了,使用本地用户登录当然无法登录,这个是很正常的。
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#7

帖子 243750496 » 2013-07-11 19:41

oneleaf 写了:你的认证都改为Mysql的虚拟用户了,使用本地用户登录当然无法登录,这个是很正常的。
不是,大神,我试过,按理说这样应该行了吧(下面),可是如果不去掉原有的内容,那么连虚拟用户都登陆不了,大神帮帮忙,谢了,各种方法都试过了,重装了10次了.....

auth sufficient pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
account sufficient pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2

# Standard behaviour for ftpd(8).

auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed

# Note: vsftpd handles anonymous logins on its own. Do not enable pam_ftp.so.

# Standard pam includes
@include common-account
@include common-session
@include common-auth
auth required pam_shells.so
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#8

帖子 243750496 » 2013-07-11 21:38

而且如果设置成了
auth required pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
account required pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
那么再还原回
# Standard behaviour for ftpd(8).

auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed

# Note: vsftpd handles anonymous logins on its own. Do not enable pam_ftp.so.

# Standard pam includes
@include common-account
@include common-session
@include common-auth
auth required pam_shells.so
本地用户仍然不能登录,我觉得这只是个bug,不是的话求解决
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#9

帖子 oneleaf » 2013-07-11 22:15

还原后,需要重启vsftpd服务。
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#10

帖子 243750496 » 2013-07-11 23:16

oneleaf 写了:还原后,需要重启vsftpd服务。
大神话说8楼的做法对么
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#11

帖子 oneleaf » 2013-07-12 9:29

243750496 写了:
oneleaf 写了:还原后,需要重启vsftpd服务。
大神话说8楼的做法对么
对。
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#12

帖子 243750496 » 2013-07-12 12:44

oneleaf 写了:
243750496 写了:
oneleaf 写了:还原后,需要重启vsftpd服务。
大神话说8楼的做法对么
对。
对不起大神是7楼的做法对么,
包括把
1、auth required 换成 auth sufficient(必须么)
2、然后放第一行(一定第一行?)
3、然后在原有文件基础上加入为如图样式么?
请回答这3个问题,没准答案就在3个问题中,谢了,劳架您了
auth sufficient pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
account sufficient pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2

# Standard behaviour for ftpd(8).

auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed

# Note: vsftpd handles anonymous logins on its own. Do not enable pam_ftp.so.

# Standard pam includes
@include common-account
@include common-session
@include common-auth
auth required pam_shells.so
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#13

帖子 oneleaf » 2013-07-12 13:13

1必须,2是,3是。
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#14

帖子 243750496 » 2013-07-12 17:17

状态: 正在连接 192.168.1.106:21...
状态: 连接建立,等待欢迎消息...
响应: 220 (vsFTPd 3.0.2)
命令: USER cc
响应: 331 Please specify the password.
命令: PASS ***********
响应: 530 Login incorrect.
错误: 严重错误
错误: 无法连接到服务器
状态: 正在连接 192.168.1.106:21...
状态: 连接建立,等待欢迎消息...
响应: 220 (vsFTPd 3.0.2)
命令: USER testuser
响应: 331 Please specify the password.
命令: PASS ******
响应: 500 OOPS: cannot change directory:/home/vsftpd/testuser
错误: 严重错误
错误: 无法连接到服务器
这是咋回事????貌似在我的实验中,很普遍,每次尝试12楼都有这个问题 我猜不是/etc/pam.d/vsftpd的问题而是/etc/pam.d/vsftpd的问题,
因为去掉
auth sufficient pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
account sufficient pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
本地用户依旧不能登录,虚拟用户也不能,如果加上了虚拟用户能登录但,本地用户依旧不能,肿么办?????
我都尝试把所有的require都改成sufficient但仍然不行(话说之前我还尝试过全部加上路径也不行)
auth sufficient /lib/security/pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
account sufficient /lib/security/pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
# Standard behaviour for ftpd(8).
auth sufficient /lib/x86_64-linux-gnu/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed

# Note: vsftpd handles anonymous logins on its own. Do not enable pam_ftp.so.

# Standard pam includes
@include common-account
@include common-session
@include common-auth
auth sufficient /lib/x86_64-linux-gnu/security/pam_shells.so
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: 设置好mysql的虚拟用户后本地用户cc无法登录了???530 Login incorrect 十万火急!!!!

#15

帖子 243750496 » 2013-07-12 17:21

tail -f /var/log/auth.log
cc@thinkpad:~$ tail -f /var/log/auth.log
Jul 12 17:20:38 thinkpad vsftpd: PAM adding faulty module: pam_xdg_support.so
Jul 12 17:20:38 thinkpad vsftpd: PAM unable to dlopen(pam_ck_connector.so): /lib/security/pam_ck_connector.so: cannot open shared object file: No such file or directory
Jul 12 17:20:38 thinkpad vsftpd: PAM adding faulty module: pam_ck_connector.so
Jul 12 17:20:38 thinkpad vsftpd: PAM unable to dlopen(pam_cap.so): /lib/security/pam_cap.so: cannot open shared object file: No such file or directory
Jul 12 17:20:38 thinkpad vsftpd: PAM adding faulty module: pam_cap.so
Jul 12 17:20:38 thinkpad vsftpd: PAM unable to dlopen(/lib/x86_64-linux-gnu/security/pam_shells.so): /lib/x86_64-linux-gnu/security/pam_shells.so: failed to map segment from shared object: Cannot allocate memory
Jul 12 17:20:38 thinkpad vsftpd: PAM adding faulty module: /lib/x86_64-linux-gnu/security/pam_shells.so
Jul 12 17:20:38 thinkpad vsftpd: PAM unable to dlopen(pam_gnome_keyring.so): /lib/security/pam_gnome_keyring.so: cannot open shared object file: No such file or directory
Jul 12 17:20:38 thinkpad vsftpd: PAM adding faulty module: pam_gnome_keyring.so
Jul 12 17:20:38 thinkpad vsftpd: pam_mysql - SELECT returned no result.
Jul 12 17:21:38 vsftpd: last message repeated 2 times
找到一片网络上的文章和我的查看log文件报的错一样(前提是还原为7楼的内容后)
今天在centos 6 64位测试安装vsftpd时发现能正常启动,但用本地用户登录时,发现出现vsftpd 530 login incorrect,出现这种错误会有很多原因。于是开始查看日志/var/log/vsftpd.log,也没发现有价值的信息。再查看/var/log/secure,发现问题了。部分错误代码如下:

Dec 1 08:07:30 localhost vsftpd: PAM adding faulty module: /lib/security/pam_listfile.so
Dec 1 08:07:30 localhost vsftpd: PAM unable to dlopen(/lib/security/pam_unix.so): /lib/security/pam_unix.so: cannot open shared objec
t file: No such file or directory
Dec 1 08:07:30 localhost vsftpd: PAM adding faulty module: /lib/security/pam_unix.so
Dec 1 08:07:30 localhost vsftpd: PAM unable to dlopen(/lib/security/pam_shells.so): /lib/security/pam_shells.so: cannot open shared o
bject file: No such file or directory
Dec 1 08:07:30 localhost vsftpd: PAM adding faulty module: /lib/security/pam_shells.so
Dec 1 08:10:12 localhost vsftpd: PAM unable to dlopen(/lib/security/pam_listfile.so): /lib/security/pam_listfile.so: cannot open shar
ed object file: No such file or directory
Dec 1 08:10:12 localhost vsftpd: PAM adding faulty module: /lib/security/pam_listfile.so
Dec 1 08:10:12 localhost vsftpd: PAM unable to dlopen(/lib/security/pam_unix.so): /lib/security/pam_unix.so: cannot open shared objec
t file: No such file or directory
Dec 1 08:10:12 localhost vsftpd: PAM adding faulty module: /lib/security/pam_unix.so
Dec 1 08:10:12 localhost vsftpd: PAM unable to dlopen(/lib/security/pam_shells.so): /lib/security/pam_shells.so: cannot open shared o
bject file: No such file or directory
Dec 1 08:10:12 localhost vsftpd: PAM adding faulty module: /lib/security/pam_shells.so

错误的意思是相关的安全验证文件找不到,通过find查找发现都在/lib64目录下,于是打开文件/etc/pam.d/vsftpd把/lib全部替换成/lib64,重启vsftpd,再登录就正常了。



大神,我
cc@thinkpad:~$ sudo find / -name pam_xdg_support.so
[sudo] password for cc:
/lib/x86_64-linux-gnu/security/pam_xdg_support.so
可是sudo gedit /etc/pam.d/vsftpd
配置文件中没有pam_xdg_support.so我怎么改?添加auth required /lib/x86_64-linux-gnu/security/pam_xdg_support.so吗??
对了顺便问一下这里(添加的这个)不能是sufficient把必须是require???
我又重装了下正常的应该报
cc@thinkpad:~$ tail -f /var/log/auth.log
Jul 12 21:30:12 thinkpad usermod[3374]: change user 'ftp' password
Jul 12 21:30:12 thinkpad chage[3379]: changed password expiry for ftp
Jul 12 21:30:12 thinkpad chfn[3382]: changed user 'ftp' information
Jul 12 21:33:04 thinkpad sudo: cc : TTY=pts/1 ; PWD=/home/cc ; USER=root ; COMMAND=/bin/cp /etc/vsftpd.conf /etc/vsftpd.conf.bk
Jul 12 21:33:04 thinkpad sudo: pam_unix(sudo:session): session opened for user root by cc(uid=0)
Jul 12 21:33:04 thinkpad sudo: pam_unix(sudo:session): session closed for user root
Jul 12 21:33:17 thinkpad sudo: cc : TTY=pts/1 ; PWD=/home/cc ; USER=root ; COMMAND=/usr/bin/gedit /etc/vsftpd.conf
Jul 12 21:33:17 thinkpad sudo: pam_unix(sudo:session): session opened for user root by cc(uid=0)
Jul 12 21:33:31 thinkpad sudo: pam_unix(sudo:session): session closed for user root
Jul 12 21:34:19 thinkpad polkitd(authority=local): Operator of unix-session:/org/freedesktop/ConsoleKit/Session1 successfully authenticated as unix-user:cc to gain TEMPORARY authorization for action org.debian.apt.install-or-remove-packages for system-bus-name::1.68 [/usr/bin/python /usr/bin/software-center] (owned by unix-user:cc)
回复