首先,咱们执行安装命令:yum install -y vsftpd服务器
执行后会自动下载,而后安装,以下:session
Loaded plugins: fastestmirror, security
Determining fastest mirrors
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 26 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 1.9 MB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================================================================
Installing:
vsftpd x86_64 2.2.2-24.el6 base 156 k
Transaction Summary
=============================================================================================================================================================================================================================================
Install 1 Package(s)
Total download size: 156 k
Installed size: 340 k
Downloading Packages:
vsftpd-2.2.2-24.el6.x86_64.rpm | 156 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vsftpd-2.2.2-24.el6.x86_64 1/1
Verifying : vsftpd-2.2.2-24.el6.x86_64 1/1
Installed:
vsftpd.x86_64 0:2.2.2-24.el6
Complete!
以上就表明安装成功了!async
安装成功后咱们进入FTP文件夹查看是否有问题,FTP在Linux上名称为 vsftpd ,默认安装在 /etc/vsftpd 目录下;ide
执行: 命令,进入FTP文件夹中查看文件,会看有四个文件,以下:this
-rw------- 1 root root 125 Mar 22 2017 ftpusers 黑名单文件,此文件里的用户不容许访问 FTP 服务器
-rw------- 1 root root 361 Mar 22 2017 user_list 白名单文件,是容许访问 FTP 服务器的用户列表
-rw------- 1 root root 4599 Mar 22 2017 vsftpd.conf 核心配置文件
-rwxr--r-- 1 root root 338 Mar 22 2017 vsftpd_conf_migrate.sh FTP服务
安装完成以后先不要着急配置,咱们先给Linux系统添加一个用户,一个登陆FTP服务器的用户;阿里云
执行 命令,建立一个 ftpuser 的用户,idea
执行 命令,修改此用户的密码。spa
这里须要限制FTP登陆的人数,咱们进入 vsftpd 目录下的 user_list 中修改,以下:debug
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
root
ftpuser
user_list 里面的内容是可以登陆FTP的用户列表,如果不想让其余用户登陆,则删除该文件内的其余用户名,仅保留咱们刚才建立的一个用户(root为系统管理员,如果不须要也能够删除)。3d
完成以上步骤咱们接下来要配置 vsftpd.conf 这个核心文件,下面是该文件里的内容:
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
此配置咱们仅须要修改一个地方,就是匿名用户登陆的时候将其禁止,而后指定FTP根目录就好了,其余的也能够自行查找网上的一些方式来配置。
修改: 改成 NO,禁止匿名用户访问。
新增: 指定用户访问主目录(FTP文件存放目录)。
可是目前没有这个文件夹,因此咱们须要建立这个文件夹,命令:
而后更改目录访问用户,命令:
使用filezilla链接试试,我出现了以下问题:
这是FTP的主动模式和被动模式形成的,因此我选择了一个很简单的方式来解决:以下
登陆成功了,而后又出现了一个新的问题:
在防火墙内开放 21 端口便可,以下:
再访问,就行了: