安裝vsftpd
? 檢查并安裝
確認虛擬機網絡連接方式
盡量虛擬機和實體機在同一IP段,如實體機:192.168.122.1 虛擬機則:192.168.122.9
確保實體機和虛擬機的ip可以互相ping通
先查看你是否安裝了vsftpd
rpm -q vsftpd
如上圖锯玛,則未安裝网棍,若已安裝,則顯示例如 vsftpd-3.0.2-10.el7.x86_64
未安裝那就安裝vsftpd
yum install -y vsftpd
如上圖历等,需要root權限
su root
然后輸入密碼讨惩,如下圖,設置root權限成功
然后繼續(xù)安裝yum install -y vsftpd
安裝完畢寒屯,如下圖荐捻。
查看到安裝的目錄whereis vsftpd
vsftpd目錄為: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz
查看vsftpd服務的狀態(tài)systemctl status vsftpd.service
開啟vsftpd服務systemctl start vsftpd.service
開啟之后再查看vsftpd服務的狀態(tài)
設置vsftpd服務開機自啟systemctl enable vsftpd.service
v防火墻設置
防火墻添加FTP服務
systemctl enable firewalld
systemctl restart firewalld
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload
firewall-cmd --reload
設置SELinux
getsebool -a | grep ftp
setsebool -P ftpd_full_access on
查看設置vi /etc/selinux/config
設置SELINUX=disabled
v配置vsftpd.conf
配置之前先備份cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf-bak
配置vsftpd.conf文件vim /etc/vsftpd/vsftpd.conf
推薦使用vim方式,vi方式配置文件注釋和實體沒有顏色區(qū)分寡夹,會看花眼的处面。
# 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
中文版的(來源于網絡):
# 是否允許匿名登錄FTP服務器,默認設置為YES允許
# 用戶可使用用戶名ftp或anonymous進行ftp登錄菩掏,口令為用戶的E-mail地址魂角。
# 如不允許匿名訪問則設置為NO
anonymous_enable=YES
# 是否允許本地用戶(即linux系統(tǒng)中的用戶帳號)登錄FTP服務器,默認設置為YES允許
# 本地用戶登錄后會進入用戶主目錄智绸,而匿名用戶登錄后進入匿名用戶的下載目錄/var/ftp/pub
# 若只允許匿名用戶訪問野揪,前面加上#注釋掉即可阻止本地用戶訪問FTP服務器
local_enable=YES
# 是否允許本地用戶對FTP服務器文件具有寫權限,默認設置為YES允許
write_enable=YES
# 掩碼瞧栗,本地用戶默認掩碼為077
# 你可以設置本地用戶的文件掩碼為缺省022斯稳,也可根據個人喜好將其設置為其他值
#local_umask=022
# 是否允許匿名用戶上傳文件,須將全局的write_enable=YES迹恐。默認為YES
#anon_upload_enable=YES
# 是否允許匿名用戶創(chuàng)建新文件夾
#anon_mkdir_write_enable=YES
# 是否激活目錄歡迎信息功能
# 當用戶用CMD模式首次訪問服務器上某個目錄時挣惰,FTP服務器將顯示歡迎信息
# 默認情況下,歡迎信息是通過該目錄下的.message文件獲得的
# 此文件保存自定義的歡迎信息,由用戶自己建立
#dirmessage_enable=YES
# 是否讓系統(tǒng)自動維護上傳和下載的日志文件
# 默認情況該日志文件為/var/log/vsftpd.log,也可以通過下面的xferlog_file選項對其進行設定
# 默認值為NO
xferlog_enable=YES
# Make sure PORT transfer connections originate from port 20 (ftp-data).
# 是否設定FTP服務器將啟用FTP數據端口的連接請求
# ftp-data數據傳輸憎茂,21為連接控制端口
connect_from_port_20=YES
# 設定是否允許改變上傳文件的屬主珍语,與下面一個設定項配合使用
# 注意,不推薦使用root用戶上傳文件
#chown_uploads=YES
# 設置想要改變的上傳文件的屬主唇辨,如果需要廊酣,則輸入一個系統(tǒng)用戶名
# 可以把上傳的文件都改成root屬主。whoever:任何人
#chown_username=whoever
# 設定系統(tǒng)維護記錄FTP服務器上傳和下載情況的日志文件
# /var/log/vsftpd.log是默認的赏枚,也可以另設其它
#xferlog_file=/var/log/vsftpd.log
# 是否以標準xferlog的格式書寫傳輸日志文件
# 默認為/var/log/xferlog亡驰,也可以通過xferlog_file選項對其進行設定
# 默認值為NO
#xferlog_std_format=YES
# 以下是附加配置,添加相應的選項將啟用相應的設置
# 是否生成兩個相似的日志文件
# 默認在/var/log/xferlog和/var/log/vsftpd.log目錄下
# 前者是wu_ftpd類型的傳輸日志饿幅,可以利用標準日志工具對其進行分析凡辱;后者是vsftpd類型的日志
#dual_log_enable
# 是否將原本輸出到/var/log/vsftpd.log中的日志,輸出到系統(tǒng)日志
#syslog_enable
# 設置數據傳輸中斷間隔時間栗恩,此語句表示空閑的用戶會話中斷時間為600秒
# 即當數據傳輸結束后透乾,用戶連接FTP服務器的時間不應超過600秒】某樱可以根據實際情況對該值進行修改
#idle_session_timeout=600
# 設置數據連接超時時間乳乌,該語句表示數據連接超時時間為120秒,可根據實際情況對其個修改
#data_connection_timeout=120
# 運行vsftpd需要的非特權系統(tǒng)用戶市咆,缺省是nobody
#nopriv_user=ftpsecure
# 是否識別異步ABOR請求汉操。
# 如果FTP client會下達“async ABOR”這個指令時,這個設定才需要啟用
# 而一般此設定并不安全蒙兰,所以通常將其取消
#async_abor_enable=YES
# 是否以ASCII方式傳輸數據磷瘤。默認情況下,服務器會忽略ASCII方式的請求搜变。
# 啟用此選項將允許服務器以ASCII方式傳輸數據
# 不過采缚,這樣可能會導致由"SIZE /big/file"方式引起的DoS攻擊
#ascii_upload_enable=YES
#ascii_download_enable=YES
# 登錄FTP服務器時顯示的歡迎信息
# 如有需要,可在更改目錄歡迎信息的目錄下創(chuàng)建名為.message的文件挠他,并寫入歡迎信息保存后
#ftpd_banner=Welcome to blah FTP service.
# 黑名單設置扳抽。如果很討厭某些email address,就可以使用此設定來取消他的登錄權限
# 可以將某些特殊的email address抵擋住殖侵。
#deny_email_enable=YES
# 當上面的deny_email_enable=YES時摔蓝,可以利用這個設定項來規(guī)定哪些郵件地址不可登錄vsftpd服務器
# 此文件需用戶自己創(chuàng)建,一行一個email address即可
#banned_email_file=/etc/vsftpd/banned_emails
# 用戶登錄FTP服務器后是否具有訪問自己目錄以外的其他文件的權限
# 設置為YES時愉耙,用戶被鎖定在自己的home目錄中贮尉,vsftpd將在下面chroot_list_file選項值的位置尋找chroot_list文件
# 必須與下面的設置項配合
#chroot_list_enable=YES
# 被列入此文件的用戶,在登錄后將不能切換到自己目錄以外的其他目錄
# 從而有利于FTP服務器的安全管理和隱私保護朴沿。此文件需自己建立
#chroot_list_file=/etc/vsftpd/chroot_list
# 是否允許遞歸查詢猜谚。默認為關閉败砂,以防止遠程用戶造成過量的I/O
#ls_recurse_enable=YES
# 是否允許監(jiān)聽。
# 如果設置為YES魏铅,則vsftpd將以獨立模式運行昌犹,由vsftpd自己監(jiān)聽和處理IPv4端口的連接請求
listen=YES
# 設定是否支持IPV6。如要同時監(jiān)聽IPv4和IPv6端口览芳,
# 則必須運行兩套vsftpd斜姥,采用兩套配置文件
# 同時確保其中有一個監(jiān)聽選項是被注釋掉的
#listen_ipv6=YES
# 設置PAM外掛模塊提供的認證服務所使用的配置文件名,即/etc/pam.d/vsftpd文件
# 此文件中file=/etc/vsftpd/ftpusers字段沧竟,說明了PAM模塊能抵擋的帳號內容來自文件/etc/vsftpd/ftpusers中
#pam_service_name=vsftpd
# 是否允許ftpusers文件中的用戶登錄FTP服務器铸敏,默認為NO
# 若此項設為YES,則user_list文件中的用戶允許登錄FTP服務器
# 而如果同時設置了userlist_deny=YES悟泵,則user_list文件中的用戶將不允許登錄FTP服務器杈笔,甚至連輸入密碼提示信息都沒有
#userlist_enable=YES/NO
# 設置是否阻扯user_list文件中的用戶登錄FTP服務器,默認為YES
#userlist_deny=YES/NO
# 是否使用tcp_wrappers作為主機訪問控制方式糕非。
# tcp_wrappers可以實現linux系統(tǒng)中網絡服務的基于主機地址的訪問控制
# 在/etc目錄中的hosts.allow和hosts.deny兩個文件用于設置tcp_wrappers的訪問控制
# 前者設置允許訪問記錄蒙具,后者設置拒絕訪問記錄。
# 如想限制某些主機對FTP服務器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主機訪問IP為192.168.57.2的FTP服務器
# 此時FTP服務器雖可以PING通,但無法連接
tcp_wrappers=YES
編輯user_list文件衡招,vim /etc/vsftpd/user_list
允許test用戶訪問FTP 注意下圖中默認UsRistListDebug
的設置融师。
默認情況下可以不編輯user_list文件。
按步驟操作以后蚁吝,效果如下:
filezilla效果圖如下:
v注意事項
- 確保關閉防火墻
systemctl stop firewalld
(臨時關閉)或者systemctl disable firewalld
(禁止開機啟動) - 查看是否安裝telnet
rpm -qa | grep telnet
- 最好安裝telnet
yum install telnet-server
FTP數字代碼的意義
重新啟動標記應答。
服務在多久時間內ready舀射。
數據鏈路端口開啟窘茁,準備傳送。
文件狀態(tài)正常脆烟,開啟數據連接端口山林。
命令執(zhí)行成功。
命令執(zhí)行失敗邢羔。
系統(tǒng)狀態(tài)或是系統(tǒng)求助響應驼抹。
目錄的狀態(tài)。
文件的狀態(tài)拜鹤。
求助的訊息框冀。
名稱系統(tǒng)類型。
新的聯機服務ready敏簿。
服務的控制連接端口關閉明也,可以注銷宣虾。
數據連結開啟,但無傳輸動作温数。
關閉數據連接端口绣硝,請求的文件操作成功。
進入passive mode撑刺。
使用者登入鹉胖。
請求的文件操作完成。
顯示目前的路徑名稱够傍。
用戶名稱正確甫菠,需要密碼。
登入時需要賬號信息王带。
請求的操作需要進一部的命令淑蔚。
無法提供服務,關閉控制連結愕撰。
無法開啟數據鏈路刹衫。
關閉聯機,終止傳輸搞挣。
請求的操作未執(zhí)行带迟。
命令終止:有本地的錯誤。
未執(zhí)行命令:磁盤空間不足囱桨。
格式錯誤仓犬,無法識別命令。
參數語法錯誤舍肠。
命令執(zhí)行失敗搀继。
命令順序錯誤。
命令所接的參數不正確翠语。
未登入叽躯。
儲存文件需要賬戶登入。
未執(zhí)行請求的操作肌括。
請求的命令終止路媚,類型未知骂租。
請求的文件終止,儲存位溢出。
未執(zhí)行請求的的命令剃盾,名稱不正確黄痪。
其他參考資料:
- CentOS7 配置FTP服務器 https://www.cnblogs.com/Zerozzx/p/7466179.html
- linux公社---CentOS 7安裝配置FTP服務器 https://www.linuxidc.com/Linux/2014-11/109233.htm
- 使用Filezilla在主機和虛擬機中傳輸文件 https://blog.csdn.net/hs794502825/article/details/7847244
- 史上最詳細的vsftpd配置文件詳解 https://www.jb51.net/article/94223.htm
- FIleZilla連接linux(Ubuntu)服務器的相關問題 https://www.cnblogs.com/yaoxing365/p/8031561.html