本教程需要您具备一定的linux使用经验,尤其是vsftpd的配置使用经验,若无,则请先补充下知识的营养吧。
一、安装vsftpd
# useradd vsftpdguest
// 添加vsftpdguest用户,作为VSFTPD的guest
# wget http://www.jjww.com.cn/upload/software/vsftpd-2.0.1-5.i386.rpm
//下载vsftpd-2.0.1-5.i386.rpm软件包
# rpm –ivh vsftpd-2.0.1-5.i386.rpm
// 安装vsftpd-2.0.1-5.i386.rpm
# rm /etc/vsftpd/vsftpd.conf
// 删除vsftpd默认的vsftpd.conf
# vi /etc/vsftpd/vsftpd.conf
// 新建并编辑vsftpd.conf文件,加入如下配置
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
chroot_local_user=YES
guest_enable=YES
guest_username=vsftpdguest
listen=YES
listen_port=21
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=30999
anon_world_readable_only=NO
virtual_use_local_privs=YES
# user_config_dir=/etc/vsftpd/vsftpd_user_conf
# service vsftpd start // 重启vsftpd
二、配置mysql/ target=_blank class=infotextkey>mysql数据库
# rpm -ivh mysql-3.23.58-1.i386.rpm
# rpm -ivh mysql-server-3.23.58-1.i386.rpm
# rpm -ivh mysql-devel-3.23.58-1.i386.rpm
// 以上是安装mysql-server的rpm包,mysql-devel包是必须安装的
# service mysqld start // 启动mysql
# mysql // mysql命令进入
mysql>create database vsftpdvu; // 新建数据库“vsftpdvu”
mysql>use vsftpdvu; // 打开数据库“vsftpdvu”
mysql>create table users(name char(20) binary,passwd char(20) binary);
//创建“users”表
mysql>insert into users (name,passwd) values ('test1','12345');
//新建FTP用户:test1密码:12345
mysql>insert into users (name,passwd) values ('test2','54321');
//新建FTP用户:test2密码:54321
mysql>grant select on vsftpdvu.users to vsftpdguest@localhost identified by '789987';
//新建一个由本地连接的mysql用户“vsftpdguest”密码为“789987”
mysql>flush privileges; // 刷新权限设置
mysql>select * from users; // 查看users表的数据
+-------+--------+
| name | passwd |
+-------+--------+
| test1 | 12345 |
| test2 | 54321 |
+-------+--------+
2 rows in set (0.00 sec)
mysql>quit
三、设置MySQL的PAM验证
注意:
crypt= n
crypt=0: 明文密码
crypt=1: 使用crpyt()函数(对应SQL数据里的encrypt(),encrypt()随机产生salt)
crypt=2: 使用MYSQL中的password()函数加密
crypt=3:表示使用md5的散列方式
# service mysqld restart // 重启mysql
四、测试vsftpd
[root@Server root]# ftp 127.0.0.1
Connected to 127.0.0.1.
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 (127.0.0.1:root): test1
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/"
ftp> bye
221 Goodbye.
[root@Server root]# ftp 127.0.0.1
Connected to 127.0.0.1.
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 (127.0.0.1:root): test2
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/"
ftp> bye
221 Goodbye.
至此,vsftpd+mysql配置完毕,希望你已有所收获。
脚本学堂,收集精品技术文章,为大家服务。