安裝vsftpd
? 檢查并安裝
確認(rèn)虛擬機(jī)網(wǎng)絡(luò)連接方式
盡量虛擬機(jī)和實(shí)體機(jī)在同一IP段,如實(shí)體機(jī):192.168.122.1 虛擬機(jī)則:192.168.122.9
確保實(shí)體機(jī)和虛擬機(jī)的ip可以互相ping通
先查看你是否安裝了vsftpd
rpm -q vsftpd
如上圖,則未安裝,若已安裝,則顯示例如 vsftpd-3.0.2-10.el7.x86_64
未安裝那就安裝vsftpd
yum install -y vsftpd
如上圖,需要root權(quán)限
su root
然后輸入密碼,如下圖,設(shè)置root權(quán)限成功
然后繼續(xù)安裝yum install -y vsftpd
安裝完畢,如下圖。
查看到安裝的目錄whereis vsftpd
vsftpd目錄為: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz
查看vsftpd服務(wù)的狀態(tài)systemctl status vsftpd.service
開啟vsftpd服務(wù)systemctl start vsftpd.service
開啟之后再查看vsftpd服務(wù)的狀態(tài)
設(shè)置vsftpd服務(wù)開機(jī)自啟systemctl enable vsftpd.service
v防火墻設(shè)置
防火墻添加FTP服務(wù)
systemctl enable firewalld
systemctl restart firewalld
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload
firewall-cmd --reload
設(shè)置SELinux
getsebool -a | grep ftp
setsebool -P ftpd_full_access on
查看設(shè)置vi /etc/selinux/config
設(shè)置SELINUX=disabled
v配置vsftpd.conf
配置之前先備份cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf-bak
配置vsftpd.conf文件vim /etc/vsftpd/vsftpd.conf
推薦使用vim方式,vi方式配置文件注釋和實(shí)體沒有顏色區(qū)分,會(huì)看花眼的。
# 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.
# When SELinux is enforcing check for SE bool ftp_home_dir
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.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#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
#
# Activate logging of uploads/downloads.
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
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
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,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
中文版的(來源于網(wǎng)絡(luò)):
# 是否允許匿名登錄FTP服務(wù)器,默認(rèn)設(shè)置為YES允許
# 用戶可使用用戶名ftp或anonymous進(jìn)行ftp登錄,口令為用戶的E-mail地址。
# 如不允許匿名訪問則設(shè)置為NO
anonymous_enable=YES
# 是否允許本地用戶(即linux系統(tǒng)中的用戶帳號(hào))登錄FTP服務(wù)器,默認(rèn)設(shè)置為YES允許
# 本地用戶登錄后會(huì)進(jìn)入用戶主目錄,而匿名用戶登錄后進(jìn)入匿名用戶的下載目錄/var/ftp/pub
# 若只允許匿名用戶訪問,前面加上#注釋掉即可阻止本地用戶訪問FTP服務(wù)器
local_enable=YES
# 是否允許本地用戶對(duì)FTP服務(wù)器文件具有寫權(quán)限,默認(rèn)設(shè)置為YES允許
write_enable=YES
# 掩碼,本地用戶默認(rèn)掩碼為077
# 你可以設(shè)置本地用戶的文件掩碼為缺省022,也可根據(jù)個(gè)人喜好將其設(shè)置為其他值
#local_umask=022
# 是否允許匿名用戶上傳文件,須將全局的write_enable=YES。默認(rèn)為YES
#anon_upload_enable=YES
# 是否允許匿名用戶創(chuàng)建新文件夾
#anon_mkdir_write_enable=YES
# 是否激活目錄歡迎信息功能
# 當(dāng)用戶用CMD模式首次訪問服務(wù)器上某個(gè)目錄時(shí),F(xiàn)TP服務(wù)器將顯示歡迎信息
# 默認(rèn)情況下,歡迎信息是通過該目錄下的.message文件獲得的
# 此文件保存自定義的歡迎信息,由用戶自己建立
#dirmessage_enable=YES
# 是否讓系統(tǒng)自動(dòng)維護(hù)上傳和下載的日志文件
# 默認(rèn)情況該日志文件為/var/log/vsftpd.log,也可以通過下面的xferlog_file選項(xiàng)對(duì)其進(jìn)行設(shè)定
# 默認(rèn)值為NO
xferlog_enable=YES
# Make sure PORT transfer connections originate from port 20 (ftp-data).
# 是否設(shè)定FTP服務(wù)器將啟用FTP數(shù)據(jù)端口的連接請(qǐng)求
# ftp-data數(shù)據(jù)傳輸,21為連接控制端口
connect_from_port_20=YES
# 設(shè)定是否允許改變上傳文件的屬主,與下面一個(gè)設(shè)定項(xiàng)配合使用
# 注意,不推薦使用root用戶上傳文件
#chown_uploads=YES
# 設(shè)置想要改變的上傳文件的屬主,如果需要,則輸入一個(gè)系統(tǒng)用戶名
# 可以把上傳的文件都改成root屬主。whoever:任何人
#chown_username=whoever
# 設(shè)定系統(tǒng)維護(hù)記錄FTP服務(wù)器上傳和下載情況的日志文件
# /var/log/vsftpd.log是默認(rèn)的,也可以另設(shè)其它
#xferlog_file=/var/log/vsftpd.log
# 是否以標(biāo)準(zhǔn)xferlog的格式書寫傳輸日志文件
# 默認(rèn)為/var/log/xferlog,也可以通過xferlog_file選項(xiàng)對(duì)其進(jìn)行設(shè)定
# 默認(rèn)值為NO
#xferlog_std_format=YES
# 以下是附加配置,添加相應(yīng)的選項(xiàng)將啟用相應(yīng)的設(shè)置
# 是否生成兩個(gè)相似的日志文件
# 默認(rèn)在/var/log/xferlog和/var/log/vsftpd.log目錄下
# 前者是wu_ftpd類型的傳輸日志,可以利用標(biāo)準(zhǔn)日志工具對(duì)其進(jìn)行分析;后者是vsftpd類型的日志
#dual_log_enable
# 是否將原本輸出到/var/log/vsftpd.log中的日志,輸出到系統(tǒng)日志
#syslog_enable
# 設(shè)置數(shù)據(jù)傳輸中斷間隔時(shí)間,此語句表示空閑的用戶會(huì)話中斷時(shí)間為600秒
# 即當(dāng)數(shù)據(jù)傳輸結(jié)束后,用戶連接FTP服務(wù)器的時(shí)間不應(yīng)超過600秒。可以根據(jù)實(shí)際情況對(duì)該值進(jìn)行修改
#idle_session_timeout=600
# 設(shè)置數(shù)據(jù)連接超時(shí)時(shí)間,該語句表示數(shù)據(jù)連接超時(shí)時(shí)間為120秒,可根據(jù)實(shí)際情況對(duì)其個(gè)修改
#data_connection_timeout=120
# 運(yùn)行vsftpd需要的非特權(quán)系統(tǒng)用戶,缺省是nobody
#nopriv_user=ftpsecure
# 是否識(shí)別異步ABOR請(qǐng)求。
# 如果FTP client會(huì)下達(dá)“async ABOR”這個(gè)指令時(shí),這個(gè)設(shè)定才需要啟用
# 而一般此設(shè)定并不安全,所以通常將其取消
#async_abor_enable=YES
# 是否以ASCII方式傳輸數(shù)據(jù)。默認(rèn)情況下,服務(wù)器會(huì)忽略ASCII方式的請(qǐng)求。
# 啟用此選項(xiàng)將允許服務(wù)器以ASCII方式傳輸數(shù)據(jù)
# 不過,這樣可能會(huì)導(dǎo)致由"SIZE /big/file"方式引起的DoS攻擊
#ascii_upload_enable=YES
#ascii_download_enable=YES
# 登錄FTP服務(wù)器時(shí)顯示的歡迎信息
# 如有需要,可在更改目錄歡迎信息的目錄下創(chuàng)建名為.message的文件,并寫入歡迎信息保存后
#ftpd_banner=Welcome to blah FTP service.
# 黑名單設(shè)置。如果很討厭某些email address,就可以使用此設(shè)定來取消他的登錄權(quán)限
# 可以將某些特殊的email address抵擋住。
#deny_email_enable=YES
# 當(dāng)上面的deny_email_enable=YES時(shí),可以利用這個(gè)設(shè)定項(xiàng)來規(guī)定哪些郵件地址不可登錄vsftpd服務(wù)器
# 此文件需用戶自己創(chuàng)建,一行一個(gè)email address即可
#banned_email_file=/etc/vsftpd/banned_emails
# 用戶登錄FTP服務(wù)器后是否具有訪問自己目錄以外的其他文件的權(quán)限
# 設(shè)置為YES時(shí),用戶被鎖定在自己的home目錄中,vsftpd將在下面chroot_list_file選項(xiàng)值的位置尋找chroot_list文件
# 必須與下面的設(shè)置項(xiàng)配合
#chroot_list_enable=YES
# 被列入此文件的用戶,在登錄后將不能切換到自己目錄以外的其他目錄
# 從而有利于FTP服務(wù)器的安全管理和隱私保護(hù)。此文件需自己建立
#chroot_list_file=/etc/vsftpd/chroot_list
# 是否允許遞歸查詢。默認(rèn)為關(guān)閉,以防止遠(yuǎn)程用戶造成過量的I/O
#ls_recurse_enable=YES
# 是否允許監(jiān)聽。
# 如果設(shè)置為YES,則vsftpd將以獨(dú)立模式運(yùn)行,由vsftpd自己監(jiān)聽和處理IPv4端口的連接請(qǐng)求
listen=YES
# 設(shè)定是否支持IPV6。如要同時(shí)監(jiān)聽I(yíng)Pv4和IPv6端口,
# 則必須運(yùn)行兩套vsftpd,采用兩套配置文件
# 同時(shí)確保其中有一個(gè)監(jiān)聽選項(xiàng)是被注釋掉的
#listen_ipv6=YES
# 設(shè)置PAM外掛模塊提供的認(rèn)證服務(wù)所使用的配置文件名,即/etc/pam.d/vsftpd文件
# 此文件中file=/etc/vsftpd/ftpusers字段,說明了PAM模塊能抵擋的帳號(hào)內(nèi)容來自文件/etc/vsftpd/ftpusers中
#pam_service_name=vsftpd
# 是否允許ftpusers文件中的用戶登錄FTP服務(wù)器,默認(rèn)為NO
# 若此項(xiàng)設(shè)為YES,則user_list文件中的用戶允許登錄FTP服務(wù)器
# 而如果同時(shí)設(shè)置了userlist_deny=YES,則user_list文件中的用戶將不允許登錄FTP服務(wù)器,甚至連輸入密碼提示信息都沒有
#userlist_enable=YES/NO
# 設(shè)置是否阻扯user_list文件中的用戶登錄FTP服務(wù)器,默認(rèn)為YES
#userlist_deny=YES/NO
# 是否使用tcp_wrappers作為主機(jī)訪問控制方式。
# tcp_wrappers可以實(shí)現(xiàn)linux系統(tǒng)中網(wǎng)絡(luò)服務(wù)的基于主機(jī)地址的訪問控制
# 在/etc目錄中的hosts.allow和hosts.deny兩個(gè)文件用于設(shè)置tcp_wrappers的訪問控制
# 前者設(shè)置允許訪問記錄,后者設(shè)置拒絕訪問記錄。
# 如想限制某些主機(jī)對(duì)FTP服務(wù)器192.168.57.2的匿名訪問,編緝/etc/hosts.allow文件,如在下面增加兩行命令:
# vsftpd:192.168.57.1:DENY 和vsftpd:192.168.57.9:DENY
# 表明限制IP為192.168.57.1/192.168.57.9主機(jī)訪問IP為192.168.57.2的FTP服務(wù)器
# 此時(shí)FTP服務(wù)器雖可以PING通,但無法連接
tcp_wrappers=YES
編輯user_list文件,vim /etc/vsftpd/user_list
允許test用戶訪問FTP 注意下圖中默認(rèn)UsRistListDebug
的設(shè)置。
默認(rèn)情況下可以不編輯user_list文件。
按步驟操作以后,效果如下:
filezilla效果圖如下:
v注意事項(xiàng)
- 確保關(guān)閉防火墻
systemctl stop firewalld
(臨時(shí)關(guān)閉)或者systemctl disable firewalld
(禁止開機(jī)啟動(dòng)) - 查看是否安裝telnet
rpm -qa | grep telnet
- 最好安裝telnet
yum install telnet-server
FTP數(shù)字代碼的意義
重新啟動(dòng)標(biāo)記應(yīng)答。
服務(wù)在多久時(shí)間內(nèi)ready。
數(shù)據(jù)鏈路端口開啟,準(zhǔn)備傳送。
文件狀態(tài)正常,開啟數(shù)據(jù)連接端口。
命令執(zhí)行成功。
命令執(zhí)行失敗。
系統(tǒng)狀態(tài)或是系統(tǒng)求助響應(yīng)。
目錄的狀態(tài)。
文件的狀態(tài)。
求助的訊息。
名稱系統(tǒng)類型。
新的聯(lián)機(jī)服務(wù)ready。
服務(wù)的控制連接端口關(guān)閉,可以注銷。
數(shù)據(jù)連結(jié)開啟,但無傳輸動(dòng)作。
關(guān)閉數(shù)據(jù)連接端口,請(qǐng)求的文件操作成功。
進(jìn)入passive mode。
使用者登入。
請(qǐng)求的文件操作完成。
顯示目前的路徑名稱。
用戶名稱正確,需要密碼。
登入時(shí)需要賬號(hào)信息。
請(qǐng)求的操作需要進(jìn)一部的命令。
無法提供服務(wù),關(guān)閉控制連結(jié)。
無法開啟數(shù)據(jù)鏈路。
關(guān)閉聯(lián)機(jī),終止傳輸。
請(qǐng)求的操作未執(zhí)行。
命令終止:有本地的錯(cuò)誤。
未執(zhí)行命令:磁盤空間不足。
格式錯(cuò)誤,無法識(shí)別命令。
參數(shù)語法錯(cuò)誤。
命令執(zhí)行失敗。
命令順序錯(cuò)誤。
命令所接的參數(shù)不正確。
未登入。
儲(chǔ)存文件需要賬戶登入。
未執(zhí)行請(qǐng)求的操作。
請(qǐng)求的命令終止,類型未知。
請(qǐng)求的文件終止,儲(chǔ)存位溢出。
未執(zhí)行請(qǐng)求的的命令,名稱不正確。
其他參考資料:
- CentOS7 配置FTP服務(wù)器 https://www.cnblogs.com/Zerozzx/p/7466179.html
- linux公社---CentOS 7安裝配置FTP服務(wù)器 https://www.linuxidc.com/Linux/2014-11/109233.htm
- 使用Filezilla在主機(jī)和虛擬機(jī)中傳輸文件 https://blog.csdn.net/hs794502825/article/details/7847244
- 史上最詳細(xì)的vsftpd配置文件詳解 https://www.jb51.net/article/94223.htm
- FIleZilla連接linux(Ubuntu)服務(wù)器的相關(guān)問題 https://www.cnblogs.com/yaoxing365/p/8031561.html