---
title: "Linux下配置VSftp服务器八步搞定"
author: "hlidc"
date: "2012-02-09T14:55:41Z"
tags: ["vsftp"]
categories: ["操作系统"]
slug: "linux-vsftp"
draft: false
lastmod: "2012-02-09T14:55:41Z"
id: 1399464
url: "https://hlidc.iteye.com/blog/1399464"
---

Linux下配置VSftp服务器步骤一、检查是否安装了vsftpd， rpm -qa ｜grep vsftp

Linux下配置VSftp服务器步骤二、新建用户

useradd test -g root -d /mpeg -s /sbin/nologin     #该用户仅用来支持FTP服务，因此不必让他登录系统

注：改变用户的shell命令为usermod -s /sbin/nologin coship

Linux下配置VSftp服务器步骤三、设置密码

passwd test    # 连续输入两次密码

Linux下配置VSftp服务器步骤四、修改SELinux参数

setsebool ftpd_disable_trans 1

service vsftpd restart

说明：如果不修改，连接时会提示

500 OOPS: cannot change directory:/mpeg

500 OOPS: child died

Linux下配置VSftp服务器步骤五、修改/mpeg权限

chmod 775 /mpeg

Linux下配置VSftp服务器步骤六、设置/etc/vsftpd/vsftpd.conf

将anonymous_enable=NO，这样可以限制匿名用户登录。

local_enable=YES       #启用本地用户登录

write_enable=YES       #设置可以进行写操作

local_umask=022        #设定上传后文件的权限掩码

userlist_enable=YES    #启用用户登录控制

local_root=/mpeg       （路径自定义）#定义所有本地用户的根目录。当本地用户登入时，将被更换到此目录下。（注释则访问该用户自己目录）

否则访问其它目录时会提示：550 Failed to change directory.

chroot_local_user=NO

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list #指出被锁定在自家目录中的用户的列表文件。文件格式为一行一用户。

注意：

当chroot_local_user=NO、chroot_list_enable=YES时，chroot_list中用户为锁定用户，即他们除了自己的目录，不可以访问其他目录。

当chroot_local_user=YES、chroot_list_enable=YES时，chroot_list中用户为非锁定用户，他们可以访问任何其他目录。

Linux下配置VSftp服务器步骤七、设置vsftpd自动启动

chkconfig vsftpd on 或

运行ntsysv将vsftpd选上 或

echo "/usr/local/sbin/vsftpd &" >>/etc/rc.local

Linux下配置VSftp服务器步骤八、如果出现不能访问的现象可以将防火墙和SELinux停用

1、service iptables stop

2、编辑/etc/selinux/config将SELINUX设为disabled，即SELINUX=disabled

或终端里运行system-config-securitylevel-tui

或点击“system"->"administration"->"security level and firewall对防火墙和SELinux进行设置

温情提示：有服务器的问题及服务器租用、托管需求的朋友联系www.163ns.com QQ:6041800 联系人：小郑
