首先,咱們執行安裝命令: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 端口便可,以下:
再訪問,就行了: