Linux下FTP服务器组建和维护

转载自 http://bbs.linuxtone.org/thread-6572-1-1.html      
作者:守住每一天
blog:www.opendoc.com.cn
bbs:bbs. linuxtone.org
测试 环境
 
centos 5.X 64bit                                      -----我的环境是RHEL5.4  32位
vsftpd 2.0

安装:yum -y install vsftpd

需求:
虚拟三个用户,使用同一个家目录。权限如下。
ftpadmin  读写删除
ftpuser   读写
ftp       读(下载)

目录为:/data
密码统一为:123456

一、创建虚拟用户 数据库
1、创建 文件文件loginuser.txt
    格式如下:
  user_id
   password
/home/loginuser.txt
ftpadmin
123456
ftpuser
123456
ftp
123456


2、生成 数据库文件:
db_load -T -t hash -f /home/loginuser.txt /etc/vsftpd/vsftpd_login.db
 
############
#运行上述命令的时候保错,yum install  db4-utils  db4-java后就可以运行这个命令了
############
ch mod 600 /etc/vsftpd/vsftpd_login.db


3、配置pam文件
# vi /etc/pam.d/vsftpd.vu
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
 
####################################
####由于我的系统是32位的,所以上述的路径是/lib/security/pam_userdb.so
####################################

二、为虚拟用户创建本地 系统用户
useradd opendoc -d /data -s /bin/false
chown opendoc.opendoc /data

三、vsftpd.conf配置
anonymous_enable=NO
local_enable=YES
#write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
listen_port=21
userlist_enable=YES
chroot_local_user=YES
tcp_wrappers=YES
guest_enable=YES
guest_username=opendoc
pam_service_name=vsftpd.vu
user_config_dir=/etc/vsftpd/vsftpd_user_conf
virtual_use_local_privs=YES
pasv_min_port=50000
pasv_max_port=60000
pasv_enable=yes
max_clients=200
max_per_ip=4
idle_session_timeout=600
ftpd_banner=Welcome to opendoc FTP service.


 
mkdir /etc/vsftpd/vsftpd_user_conf

# vi /etc/vsftpd/vsftpd_user_conf/ftpadmin 所有权限
write_enable=YES
anonymous_enable=NO
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_umask=022
download_enable=Yes
local_root=/data


# vi /etc/vsftpd/vsftpd_user_conf/ftpuser 上传权限
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_umask=022
download_enable=NO
local_root=/data


# vi /etc/vsftpd/vsftpd_user_conf/ftp 只能下载
write_enable=NO
anon_world_readable_only=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
local_umask=022
download_enable=yes
local_root=/data


# /etc/init.d/vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]


测试:
# ftp -n localhost
Connected to ifidc.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
220 Welcome to tfhudong FTP service
ftp> use ftpadmin
331 Please specify the password.
Password:
230 Login successful.
ftp> quit
221 Goodbye.

# ftp -n localhost
Connected to ifidc.
220 Welcome to tfhudong FTP service
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
ftp> use ftpuser
331 Please specify the password.
Password:
230 Login successful.
ftp> quit
221 Goodbye.

# ftp -n localhost              
Connected to ifidc.
220 Welcome to tfhudong FTP service
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
ftp> use ftp
331 Please specify the password.
Password:
230 Login successful.
ftp> quit
221 Goodbye.
 

你可能感兴趣的:(linux,ftp,服务器,维护,组建)