转自:http://chaos.blog.51cto.com/415914/470503

1、安装vsftp,本文采用yum安装:

#yum install vsftpd

2、安装后运行:

# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

3、新增加系统用户:

#useradd -d /home/chaosdir -s /sbin/nologin chaos  //增加新用户不让在本机登陆
#chown -R chaos /home/chaosdir  //更改新增目录的权限,只允许chaos访问此目录;
#chmod 777 -R /home/chaosdir
# passwd chaos                         //为用户设置密码;
Changing password for user chaos.
New UNIX password:
BAD PASSWORD: it does not contain enough DIFFERENT characters
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

5、修改vsftpd.conf 禁止匿名帐号登陆及允许自建帐号登陆:

#vi /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_std_format=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

4、修改/etc/vsftpd/chroot_list 添加chaos 帐号允许该帐号登陆FTP服务器
5、在linux Shell 命令模式下

#setsebool ftpd_disable_trans 1                       // 关闭掉Selinux 对ftp服务的保护;
#vi /etc/selinux/config
SELINUX=disabled                                            //将此处设置为Disable
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted – Only targeted network daemons are protected.
#       strict – Full SELinux protection.
SELINUXTYPE=targeted

重启服务

# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]