系统环境:192.168.1.62. centos6.4 64位系统
安装vsftp的软件包
yum install vsftpd
2.虚拟用户需要一个数据库的转换。安装所需要的软件
yum install db4*
vftpuser.txt这个文件里面写上你的用户名和密码。这个文件原本是不存在的 创建即可。然后再格式转换
db_load -T -t hash �Cf vftpuser.txt vftpuser.db 转换数据格式
3.增加pam认证 安装pam所需要的包
yum install pam*
cd /etc/pam.d/
cp vsftpd vsftpduser
编辑pam的配置文件
[root@jboss1 pam.d]# cat vsftpduser
#%PAM-1.0
auth required/lib64/security/pam_userdb.so db=/etc/vsftpd/vftpuser
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vftpuser
这个错误可以从/var/log/secure里面看出来
Sep 12 15:19:30 localhost sshd[24698]: Accepted password for root from 192.168.12.125 port 58767 ssh2
Sep 12 15:19:31 localhost sshd[24698]: pam_unix(sshd:session): session opened for user root by (uid=0)
Sep 12 15:41:19 localhost vsftpd[25062]: PAM unable to dlopen(/lib/security/pam_userdb.so): /lib/security/pam_userdb.so: cannot open shared object file: No such file or directory
Sep 12 15:41:19 localhost vsftpd[25062]: PAM adding faulty module: /lib/security/pam_userdb.so
Sep 12 15:41:20 localhost vsftpd[25064]: PAM unable to dlopen(/lib/security/pam_userdb.so): /lib/security/pam_userdb.so: cannot open shared object file: No such file or directory
Sep 12 15:41:20 localhost vsftpd[25064]: PAM adding faulty module: /lib/security/pam_userdb.so
4.增加真实用户
useradd -d /var/total virtualuser
usermod -s /sbin/nologin virtualuser
5.编辑vsftpd.conf的文件
[root@localhost pam.d]# grep -vE "#|^$" /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
dual_log_enable=YES
vsftpd_log_file=/var/log/vsftpd.log
chroot_local_user=YES
listen=YES
pam_service_name=vsftpduser pam的配置文件
guest_enable=YES
guest_username=virtualuser
user_config_dir=/etc/vsftpd/user_conf用户配置的文件目录
local_root=/var/total/文件存放处
userlist_enable=YES
tcp_wrappers=YES
pasv_enable=YES
pasv_min_port=64000
pasv_max_port=65535
max_clients=30
max_per_ip=50
local_max_rate=512000
6.配置虚拟用户的配置
cd /etc/vsftpd
mkdir user_conf
cd user_conf
touch gaohuina
local_root=/var/total/test
anon_world_readable_only=NO
anonymous_enable=NO
write_enable=NO
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
idle_session_timeout=2000
data_connection_timeout=500
max_clients=30
max_per_ip=10
local_max_rate=50000
cmds_allowed=ABOR,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RETR,RNFR,RNTO,SIZE,STOR,TYPE,USER,REST,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST,FEAT
file_open_mode=0444
7.配置好了之后重启vsftpd进程