作者:心跳-很执着 | 来源:互联网 | 2014-05-28 09:06
1、安装软件sudoapt-getinstallvsftp;sudoapt-getinstallmysql-serversudoapt-getinstallmysql-client;sudoapt-getinstalllibpam-mysql;2、创建系统用户sudouseradd-d/home/vsftpd-s/bi
1、安装软件
sudo apt-get install vsftp;
sudo apt-get install mysql-server
sudo apt-get install mysql-client;
sudo apt-get install libpam-mysql;
2、创建系统用户
sudo useradd -d /home/vsftpd -s /bin/false vsftpd;
sudo passwd vsftpd;
sudo mkdir /home/vsftpd;
sudo chown vsftpd:vsftpd /home/vsftpd;
sudo chmod -R 700 /home/vsftpd;
3、创建虚拟用户数据库和数据库用户
create database vsftpd;
create table users(name char(20),passwd char(20));
insert into users (name,passwd) values ('test','test');
grant select,insert on vsftpd.users to vsftpd@localhost identified
by 'vsftpd';
4、设置授权方式指定mysql信息
修改如下文件
/etc/pam.d/vsftpd
auth required /lib/security/pam_mysql.so user=vsftpd
passwd=vsftpd host=localhost db=vsftpd table=users usercolumn=name
passwdcolumn=passwd crypt=0
account required /lib/security/pam_mysql.so user=vsftpd
passwd=vsftpd host=localhost db=vsftpd table=users usercolumn=name
passwdcolumn=passwd crypt=0
5、创建虚拟用户目录,指定用户根目录和其他个性化参数
sudo mkdir /etc/vsftpd/userconf;
cd /etc/vsftpd/userconf;
sudo touch test;
修改test内容为
local_root=/data/
write_enable=YES
download_enable=YES
#anon_world_readable_Only=NO
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
#anon_umask=022
6、重启服务
sudo service vsftpd restart;
7、修改/etc/vsftpd.conf
listen=YES
listen_port=21
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
tcp_wrappers=YES
guest_enable=YES
guest_username=www-data
chmod_enable=YES
virtual_use_local_privs=YES
passwd_chroot_enable=NO
user_config_dir=/etc/vsftpd/userconf
pasv_min_port=10000
pasv_max_port=10100
use_localtime=YES
max_clients=10
max_per_ip=5
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
idle_session_timeout=600
data_connection_timeout=120
ftpd_banner=Welcome
chroot_local_user=YES
ls_recurse_enable=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list