打开终端Terminal
安装vsftpd、mysql-server、mysql-client、libpam-mysql
命 令:
apt-get install vsftpd mysql-server mysql-client libpam-mysql
注 意:在非root下安装需在指令前加sudo
一、配置vsftpd
备份初始的/etc/vsftpd.conf文件,创建新的配置文件
cp /etc/vsftpd.conf /etc/vsftpd.conf_orig
cat /dev/null > /etc/vsftpd.conf
vi /etc/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
重启 vsftpd
service vsftpd restart
或者
/etc/init.d/vsftpd restart
二、新建数据库
新建系 统管理员(操作系统)
useradd -m vsftpdguest
进入
mysql -u root -p
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验证
备份原有文配置文件,并修改
cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd_orig
cat /dev/null > /etc/pam.d/vsftpd
vi /etc/pam.d/vsftpd
加入以下内容
auth required /lib/security/pam_mysql.so user=vsftpdguest passwd=789987 host=localhost db=vsftpdvu table=users usercolumn=name passwdcolumn=passwd crypt=0 account required /lib/security/pam_mysql.so user=vsftpdguest passwd=789987 host=localhost db=vsftpdvu table=users usercolumn=name passwdcolumn=passwd crypt=0
注:以 上是两行内容
重启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.
test1 与test2都登录到vsftpdguest的目录下
--转自