当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 9 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 菜鸟ubuntu8.04桌面版配置vsftp+mysql+pam 无法使用
帖子发表于 : 2008-09-10 15:33 

注册: 2008-09-10 15:12
帖子: 48
送出感谢: 0 次
接收感谢: 0 次
我是根据下面配置:
因为工作需要安装一个ftp服务器,需要使用多ftp用户并能够方便的管理ftp用户。于是使用vsftp+mysql+pam的组合,在mysql中进行用户管理。特写了这么一个记录安装过程的文章,提供给大家一起讨论。

1.安装vsftpd

代码:
sudo apt-get install vsftpd


2.创建guest用户

vsftpd安装的时候会自动安转一个ftp用户,在passwd中删除

代码:
sudo useradd real

代码:
sudo passwd real


代码:
sudo vim /etc/passwd


3.设置mysql数据库和用户权限

在phpmyadmin中建立vsftp数据库 vsftp用户
安装mysql
设置mysql权限
sudo apt-get install mysql-server
设置mysql密码 sunday

mysql>create database vsftpid;
  mysql>use vsftpid;
  mysql>create table vsftp(name char(16) binary,passwd char(16) binary);
  mysql>insert into vsftp (name,passwd) values ('real',password('real'));
  
  
并授权限,并设置密码
mysql>grant select on vsftpid.vsftp to real_root@localhost identified by 'real';

+------+------------------+
| name | passwd |
+------+------------------+
| real | *CD538865C03D379 |
+------+------------------+
1 row in set (0.00 sec)

mysql 设置成功

4.设置MySQL的PAM验证

安装libpam-mysql

代码:
sudo apt-get install libpam-mysql


要设置vsftpd的PAM验证文件

代码:
sudo cp /usr/share/doc/vsftpd/EXAMPLE/VIRTUAL_USERS/vsftpd.pam /etc/pam.d/vsftpd

把内容替换为如下:

代码:
auth required /lib/security/pam_mysql.so user=real_root passwd=real host=localhost db=vsftpid table=vsftp usercolumn=name passwdcolumn=passwd crypt=2
account required /lib/security/pam_mysql.so user=real_root passwd=real host=localhost db=vsftpid table=vsftp usercolumn=name passwdcolumn=passwd crypt=2

5.设置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? (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=YES
#
guest_enable=YES
guest_username=real
user_config_dir=/etc/vsftpd
# 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 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().
#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
#
#
# Debian customization
#
# Some of vsftpd's settings don't fit the Debian filesystem layout by
# default. These settings are more Debian-friendly.
#
# 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=/home/ftp
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# 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

6.虚拟用户目录的权限改为只能由real操作:

代码:
sudo chown real.real /home/ftp/real
sudo chmod 755 /home /ftp/real


代码:
sudo /etc/init.d/vsftpd restart

连接后显示为
USER real

331 Please specify the password.
PASS xxxx
530 Login incorrect.
正在断开与站点 192.168.4.9 的连接

各位大侠 是什么问题?????????


最后由 yinsuntoday 编辑于 2008-09-16 14:28,总共编辑了 4 次

页首
 用户资料  
 
2 楼 
 文章标题 :
帖子发表于 : 2008-09-10 16:05 

注册: 2007-08-27 17:31
帖子: 445
送出感谢: 0 次
接收感谢: 1
你在论坛搜索下吧,曾经写过一个帖子的


_________________
你能学会世界上所有语言来叫一种鸟的名字,当你知道所有这些名字叫法后,却对这种鸟一无所知~
理查德-费曼


页首
 用户资料  
 
3 楼 
 文章标题 :
帖子发表于 : 2008-09-10 16:11 
头像

注册: 2007-10-29 22:12
帖子: 5353
地址: 江苏南京
系统: OSX 10.9 + Ub 1304
送出感谢: 0 次
接收感谢: 5
个人感觉pureftpd比vsftpd要好用很多,而且它的very secure没看到secure在哪


_________________
佛经说,人有八苦: 生、老、病、死、求不得、怨憎、爱别离、五阴盛 故我苦!
圣经说,人有七罪: 饕餮、贪婪、懒惰、淫欲、傲慢、嫉妒和暴怒  故我有罪!

我这篇帖子里面没有任何攻击我们伟大的中华人民共和国政府和任劳任怨的人民公仆(和本论坛高素质的版主)的文字和含义;

特此声明!

有些事,我们明知道是错的,也要去坚持,因为不甘心;有些人,我们明知道是爱的,也要去放弃,因为没结局;有时候,我们明知道没路了,却还在前行,因为习惯了。

欢迎来我的新浪微博@me


页首
 用户资料  
 
4 楼 
 文章标题 :
帖子发表于 : 2008-09-10 20:24 
头像

注册: 2006-09-13 23:59
帖子: 56
送出感谢: 0 次
接收感谢: 0 次
mysql>create database vsftpdid;

auth required /lib/security/pam_mysql.so user=real_root passwd=real host=localhost db=vsftpid table=vsftp usercolumn=name passwdcolumn=passwd crypt=2


[/b]


页首
 用户资料  
 
5 楼 
 文章标题 :
帖子发表于 : 2008-09-11 10:48 

注册: 2008-09-10 15:12
帖子: 48
送出感谢: 0 次
接收感谢: 0 次
还是无法连接
正在查阅 192.168.4.9
尝试 192.168.4.9:21
已连接到 192.168.4.9:21
220 (vsFTPd 2.0.6)
USER real

331 Please specify the password.
PASS xxxx
530 Login incorrect.
正在断开与站点 192.168.4.9 的连接


页首
 用户资料  
 
6 楼 
 文章标题 :
帖子发表于 : 2008-09-11 23:03 
头像

注册: 2006-09-13 23:59
帖子: 56
送出感谢: 0 次
接收感谢: 0 次
account required /lib/security/pam_mysql.so user=real_rootl passwd=real host=localhost db=vsftpid table=vsftp usercolumn=name passwdcolumn=passwd crypt=2


页首
 用户资料  
 
7 楼 
 文章标题 :
帖子发表于 : 2008-09-12 10:06 

注册: 2008-09-10 15:12
帖子: 48
送出感谢: 0 次
接收感谢: 0 次
account required /lib/security/pam_mysql.so user=real_rootl passwd=real host=localhost db=vsftpid table=vsftp usercolumn=name passwdcolumn=passwd crypt=2
我更改了但还不行


页首
 用户资料  
 
8 楼 
 文章标题 : Re: 菜鸟ubuntu8.04桌面版配置vsftp+mysql+pam 无法使用
帖子发表于 : 2008-10-28 8:43 

注册: 2007-09-05 16:44
帖子: 22
送出感谢: 0 次
接收感谢: 0 次
create table vsftp(name char(16) binary,passwd char(16) binary);
这一句的问题.
用了crypt=2 的话,mysql生成的密码会有48位长.
而passwd char(16)只有16位长,你怎么验证,密码都会是错的.
刚试出来,网上很多这样转贴的人我都怀疑有没有自己测试.
晕死了.


页首
 用户资料  
 
9 楼 
 文章标题 : Re: 菜鸟ubuntu8.04桌面版配置vsftp+mysql+pam 无法使用
帖子发表于 : 2008-10-28 18:07 

注册: 2007-08-27 17:31
帖子: 445
送出感谢: 0 次
接收感谢: 1
恩,楼上说的很有可能,当时我测试用的crypt=0,没有问题
用2的时候用的图形工具,没有通过,还以为是工具的问题!
不过mysql的passwd()加密没有那么多位吧
+----+-------+------------------+
| id | name | passwd |
+----+-------+------------------+
| 1 | tony | 2351315b1bd1bd58 |
| 2 | etony | 59c0cde4781fb0be |
+----+-------+------------------+
正好是16位,创建的时候使用20或许更合适


_________________
你能学会世界上所有语言来叫一种鸟的名字,当你知道所有这些名字叫法后,却对这种鸟一无所知~
理查德-费曼


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 9 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:Google [Bot] 和 2 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译