《VSftpd安裝和配置FTP虛擬用戶(hù)實(shí)踐》要點(diǎn):
本文介紹了VSftpd安裝和配置FTP虛擬用戶(hù)實(shí)踐,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
VSftpd英文全稱(chēng)(Very Secure File Transfer Protocol Deamon),正如VSftpd官方宣傳中所說(shuō)Probably the most secure and fastest FTP server for UNIX-like systems
.我相信這是大多數(shù)人選擇VSftpd來(lái)搭建Linux的FTP服務(wù)器的原因,當(dāng)然ProFTPD用的人應(yīng)該也不在少數(shù).本文將以清晰直觀的方式介紹安裝VSftpd以及配置FTP虛擬用戶(hù)的過(guò)程,希望對(duì)大家有幫助.
$ yum -y install vsftpd* pam* db4* ftp
$ useradd vsftpd -s /sbin/nologin
默認(rèn)的VSftpd的服務(wù)宿主用戶(hù)是root,但是這不符合安全性的需要.這里建立名字為vsftpd的用戶(hù),用他來(lái)作為支持VSftpd的服務(wù)宿主用戶(hù).由于該用戶(hù)僅用來(lái)支持VSftpd服務(wù)用,因此沒(méi)有許可他登陸系統(tǒng)的必要,并設(shè)定他為不能登陸系統(tǒng)的用戶(hù).
$ useradd virtual -d /home/ftpdata/ -s /sbin/nologin
$ chown -R virtual:virtual /home/ftpdata/
VSftpd的虛擬用戶(hù)并不是系統(tǒng)用戶(hù),也就是說(shuō)這些FTP的用戶(hù)在系統(tǒng)中是不存在的.他們的總體權(quán)限其實(shí)是集中寄托在一個(gè)在系統(tǒng)中的某一個(gè)用戶(hù)身上的,所謂VSftpd的虛擬宿主用戶(hù),就是這樣一個(gè)支持著所有虛擬用戶(hù)的宿主用戶(hù).由于他支撐了FTP的所有虛擬的用戶(hù),那么他本身的權(quán)限將會(huì)影響著這些虛擬的用戶(hù),因此出于安全性的考慮,也要非常注意對(duì)該用戶(hù)的權(quán)限的控制,該用戶(hù)也絕對(duì)沒(méi)有登陸系統(tǒng)的必要,這里也設(shè)定他為不能登陸系統(tǒng)的用戶(hù).
anonymous_enable=YES|NO
控制是否允許匿名用戶(hù)登錄,YES允許,NO不允許,默認(rèn)值為YES.
ftp_username= username
匿名用戶(hù)所使用的系統(tǒng)用戶(hù)名.默認(rèn)下,此參數(shù)在配置文件中不出現(xiàn),值為ftp
no_anon_password=YES|NO
控制匿名用戶(hù)登入時(shí)是否需要密碼,YES不需要,NO需要.默認(rèn)值為NO.
anon_root=path
設(shè)定匿名用戶(hù)的根目錄,即匿名用戶(hù)登入后,被定位到此目錄下.主配置文件中默認(rèn)無(wú)此項(xiàng),默認(rèn)值為/var/ftp/.
anon_world_readable_only=YES|NO
控制是否只允許匿名用戶(hù)下載可閱讀文檔.YES,只允許匿名用戶(hù)下載可閱讀的文件.NO,允許匿名用戶(hù)瀏覽整個(gè)服務(wù)器的文件系統(tǒng).默認(rèn)值為YES.
anon_upload_enable=YES|NO
控制是否允許匿名用戶(hù)上傳文件,YES允許,NO不允許,默認(rèn)是不設(shè)值,即為NO.除了這個(gè)參數(shù)外,匿名用戶(hù)要能上傳文件,還需要兩個(gè)條件:一,write_enable參數(shù)為YES;二,在文件系統(tǒng)上,FTP匿名用戶(hù)對(duì)某個(gè)目錄有寫(xiě)權(quán)限.
anon_mkdir_write_enable=YES|NO
控制是否允許匿名用戶(hù)創(chuàng)建新目錄,YES允許,NO不允許,默認(rèn)是不設(shè)值,即為NO.當(dāng)然在文件系統(tǒng)上,FTP匿名用戶(hù)必需對(duì)新目錄的上層目錄擁有寫(xiě)權(quán)限.
anon_other_write_enable=YES|NO
控制匿名用戶(hù)是否擁有除了上傳和新建目錄之外的其他權(quán)限,如刪除、更名等.YES擁有,NO不擁有,默認(rèn)值為NO.
chown_uploads=YES|NO
是否修改匿名用戶(hù)所上傳文件的所有權(quán).YES,匿名用戶(hù)所上傳的文件的所有權(quán)將改為另外一個(gè)不同的用戶(hù)所有,用戶(hù)由chown_username參數(shù)指定.此選項(xiàng)默認(rèn)值為NO.
chown_username=whoever
指定擁有匿名用戶(hù)上傳文件所有權(quán)的用戶(hù)
local_enable=YES|NO
控制vsftpd所在的系統(tǒng)的用戶(hù)是否可以登錄vsftpd.默認(rèn)值為YES.
local_root=
定義所有本地用戶(hù)的根目錄.當(dāng)本地用戶(hù)登入時(shí),將被更換到此目錄下.默認(rèn)值為無(wú).
user_config_dir=
定義用戶(hù)個(gè)人配置文件所在的目錄.用戶(hù)的個(gè)人配置文件為該目錄下的同名文件
chroot_list_enable=YES|NO
鎖定某些用戶(hù)在自家目錄中.即當(dāng)這些用戶(hù)登錄后,不可以轉(zhuǎn)到系統(tǒng)的其他目錄,只能在自家目錄(及其子目錄)下.具體的用戶(hù)在chroot_list_file參數(shù)所指定的文件中列出.默認(rèn)值為NO.
chroot_list_file=/etc/vsftpd/chroot_list
指出被鎖定在自家目錄中的用戶(hù)的列表文件.文件格式為一行一用戶(hù).通常該文件是/etc/vsftpd/chroot_list.此選項(xiàng)默認(rèn)不設(shè)置.
chroot_local_users=YES|NO
將本地用戶(hù)鎖定在自家目錄中.當(dāng)此項(xiàng)被激活時(shí),chroot_list_enable和chroot_local_users參數(shù)的作用將發(fā)生變化,chroot_list_file所指定文件中的用戶(hù)將不被鎖定在自家目錄.本參數(shù)被激活后,可能帶來(lái)安全上的沖突,特別是當(dāng)用戶(hù)擁有上傳、shell訪問(wèn)等權(quán)限時(shí).因此,只有在確實(shí)了解的情況下,才可以打開(kāi)此參數(shù).默認(rèn)值為NO.
passwd_chroot_enable =YES|NO
當(dāng)此選項(xiàng)激活時(shí),與chroot_local_user選項(xiàng)配合,chroot()容器的位置可以在每個(gè)用戶(hù)的基礎(chǔ)上指定.每個(gè)用戶(hù)的容器來(lái)源于/etc/passwd中每個(gè)用戶(hù)的自家目錄字段.默認(rèn)值為NO.
listen_address=ip address
定義了在主機(jī)的哪個(gè)IP地址上監(jiān)聽(tīng)FTP請(qǐng)求
listen_port=port_value ?
指定FTP服務(wù)器監(jiān)聽(tīng)的端口號(hào)(控制端口),默認(rèn)值為21.此選項(xiàng)在standalone模式下生效
port_enable=YES|NO
指定數(shù)據(jù)連接時(shí)模式,默認(rèn)值為YES(PORT模式,NO為PASV模式)
connect_from_port_20=YES|NO
控制以PORT模式進(jìn)行數(shù)據(jù)傳輸時(shí)是否使用20端口(ftp-data)
ftp_data_port=port number
設(shè)定ftp數(shù)據(jù)傳輸端口(ftp-data)值.默認(rèn)值為20.此參數(shù)用于PORT FTP模式.
pasv_enable=YES|NO
YES,允許數(shù)據(jù)傳輸時(shí)使用PASV模式.NO,不允許使用PASV模式.默認(rèn)值為YES.
pasv_min_port=port number
pasv_max_port=port number
設(shè)定在PASV模式下,建立數(shù)據(jù)傳輸所可以使用port范圍的下界和上界,0 表 ? ?示任意.默認(rèn)值為0.把端口范圍設(shè)在比較高的一段范圍內(nèi),比如50000-60000,將有助于安全性的提高
pasv_address= ip address
此選項(xiàng)為一個(gè)數(shù)字IP地址,作為PASV命令的響應(yīng).默認(rèn)值為none,即地址是從呼入的連接套接字(incoming connectd socket)中獲取.
ascii_upload_enable=YES|NO
控制是否允許使用ascii模式上傳文件,YES允許,NO不允許,默認(rèn)為NO
ascii_download_enable=YES|NO
控制是否允許使用ascii模式下載文件,YES允許,NO不允許,默認(rèn)為NO.
idle_session_timeout= numerical value
空閑用戶(hù)會(huì)話的超時(shí)時(shí)間,若是超出這時(shí)間沒(méi)有數(shù)據(jù)的傳送或是指令的輸入,則會(huì)強(qiáng)迫斷線.單位為秒,默認(rèn)值為300.
data_connection_timeout= numerical value
空閑的數(shù)據(jù)連接的超時(shí)時(shí)間.默認(rèn)值為300 秒.
accept_timeout=numerical value
接受建立聯(lián)機(jī)的超時(shí)設(shè)定,單位為秒.默認(rèn)值為60.
connect_timeout=numerical value
響應(yīng)PORT方式的數(shù)據(jù)聯(lián)機(jī)的超時(shí)設(shè)定,單位為秒.默認(rèn)值為60
max_clients=numerical value
此參數(shù)在VSFTPD使用單獨(dú)(standalone)模式下有效.此參數(shù)定義了FTP服務(wù)器最大的并發(fā)連接數(shù),當(dāng)超過(guò)此連接數(shù)時(shí),服務(wù)器拒絕客戶(hù)端連接.默認(rèn)值為0,表示不限最大連接數(shù).
max_per_ip=numerical value
此參數(shù)在VSFTPD使用單獨(dú)(standalone)模式下有效.此參數(shù)定義每個(gè)IP地址最大的并發(fā)連接數(shù)目.超過(guò)這個(gè)數(shù)目將會(huì)拒絕連接.此選項(xiàng)的設(shè)置將影響到象網(wǎng)際快車(chē)這類(lèi)的多進(jìn)程下載軟件.默認(rèn)值為0,表示不限制.
anon_max_rate=value
設(shè)定匿名用戶(hù)的最大數(shù)據(jù)傳輸速度value,以Bytes/s為單位.默認(rèn)無(wú).
local_max_rate=value
設(shè)定用戶(hù)的最大數(shù)據(jù)傳輸速度value,以Bytes/s為單位.默認(rèn)無(wú).
write_enable=YES
設(shè)定允許進(jìn)行寫(xiě)操作(上傳、刪除),默認(rèn)為YES,可選值【yes,no】
local_umask=022
設(shè)定權(quán)限掩碼,默認(rèn)022,對(duì)應(yīng)的文件上傳權(quán)限644、目錄權(quán)限755
dirmessage_enable=YES
設(shè)定開(kāi)啟目錄標(biāo)語(yǔ)功能
xferlog_enable=YES
設(shè)定開(kāi)啟日志記錄功能
xferlog_file=/var/log/ftp/vsftpd.log
設(shè)置日志目錄
xferlog_std_format=YES
設(shè)定日志使用標(biāo)準(zhǔn)的記錄格式
nopriv_user=vsftpd
設(shè)定支撐Vsftpd服務(wù)的宿主用戶(hù)為手動(dòng)建立的Vsftpd用戶(hù).注意,一旦做出更改宿主用戶(hù)后,必須注意一起與該服務(wù)相關(guān)的讀寫(xiě)文件的讀寫(xiě)賦權(quán)問(wèn)題.比如日志文件就必須給與該用戶(hù)寫(xiě)入權(quán)限等.
async_abor_enable=YES
設(shè)定支持異步傳輸功能.
ftpd_banner=This Vsftp server supports virtual users ^_^
設(shè)定Vsftpd的登陸標(biāo)語(yǔ).
deny_email_enable=YES
可將某些特殊的 email address 抵擋住.如果以anonymous 登錄服務(wù)器時(shí),會(huì)要求輸入密碼,也就是您的email address, 如果很討厭某些email address ,就可以使用此設(shè)定來(lái)取消他的登錄權(quán)限,但必須與下面的設(shè)置項(xiàng)配合
banned_email_file=/etc/vsftpd/banned_emails
當(dāng)上面的 deny_email_enable=YES 時(shí),可以利用這個(gè)設(shè)定項(xiàng)來(lái)規(guī)定那個(gè)email address 不可登錄vsftpd 服務(wù)器,此文件需用戶(hù)自己創(chuàng)建,一行一個(gè)email address 即可!
ls_recurse_enable=YES
是否允許遞歸查詢(xún) , 大型站點(diǎn)的 FTP 服務(wù)器啟用此項(xiàng)可以方便遠(yuǎn)程用戶(hù)查詢(xún)
chroot_local_user=YES
listen=YES
如果設(shè)置為 YES , 則 vsftpd 將以獨(dú)立模式運(yùn)行,由vsftpd 自己監(jiān)聽(tīng)和處理連接請(qǐng)求
listen_ipv6=YES
設(shè)定是否支持IPV6
pam_service_name=vsftpd
設(shè)置 PAM 外掛模塊提供的認(rèn)證服務(wù)所使用的配置文件名 ,即/etc/pam.d/vsftpd 文件,此文件中file=/etc/vsftpd/ftpusers 字段,說(shuō)明了PAM 模塊能抵擋的帳號(hào)內(nèi)容來(lái)自文件/etc/vsftpd/ftpusers 中
userlist_enable=YES/NO
此選項(xiàng)默認(rèn)值為NO , 此時(shí)ftpusers 文件中的用戶(hù)禁止登錄FTP 服務(wù)器;若此項(xiàng)設(shè)為YES ,則 user_list 文件中的用戶(hù)允許登錄 FTP 服務(wù)器,而如果同時(shí)設(shè)置了 userlist_deny=YES ,則 user_list 文件中的用戶(hù)將不允許登錄FTP 服務(wù)器,甚至連輸入密碼提示信息都沒(méi)有,直接被FTP 服務(wù)器拒絕
userlist_deny=YES/NO
此項(xiàng)默認(rèn)為YES ,設(shè)置是否阻扯user_list 文件中的用戶(hù)登錄FTP 服務(wù)器
tcp_wrappers=YES
表明服務(wù)器使用 tcp_wrappers 作為主機(jī)訪問(wèn)控制方式,tcp_wrappers 可以實(shí)現(xiàn)linux 系統(tǒng)中網(wǎng)絡(luò)服務(wù)的基于主機(jī)地址的訪問(wèn)控制,在/etc 目錄中的hosts.allow 和hosts.deny 兩個(gè)文件用于設(shè)置tcp_wrappers 的訪問(wèn)控制,前者設(shè)置允許訪問(wèn)記錄,后者設(shè)置拒絕訪問(wèn)記錄.例如想限制某些主機(jī)對(duì)FTP 服務(wù)器192.168.57.2 的匿名訪問(wèn),編緝/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ī)訪問(wèn)IP 為192.168.57.2 的FTP 服務(wù)器,此時(shí)FTP 服務(wù)器雖可以PING 通,但無(wú)法連接
ftpusers:禁止user_list列表中的用戶(hù)訪問(wèn)FTP
userlist_enable=YES,userlist_deny=YES,禁止user_list列表中的用戶(hù)訪FTP
userlist_enable=YES,userlist_deny=NO,只允許user_list列表中的用戶(hù)FTP.
userlist_enable=NO,userlist_deny=YES,因設(shè)定userlist_enable=NO,忽略u(píng)ser_list文件,user_list不啟作用
userlist_enable=NO,userlist_deny=NO,因設(shè)定userlist_enable=NO,忽略u(píng)ser_list文件,user_list不啟作用
ftpusers禁止的優(yōu)先級(jí)更高.假設(shè)ftpusers禁止woodie用戶(hù)訪問(wèn),userlist允許woodie用戶(hù)訪問(wèn),則在運(yùn)行時(shí),用戶(hù)woodie不能訪問(wèn)ftp.
$ vim /etc/vsftpd/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=NO
#
# 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,
# 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().
#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=YES
#listen_port=56880
pasv_min_port=30000
pasv_max_port=35000
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd.vu
#pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
chroot_local_user=YES
guest_enable=YES
guest_username=virtual
virtual_use_local_privs=YES
#reverse_lookup_enable=NO
user_config_dir=/etc/vsftpd/vsftpd_user_conf
$ vim /etc/vsftpd/ftpuser.txt
ftpupload
12345678
格式很簡(jiǎn)單:”一行用戶(hù)名,一行密碼!”.
db_load命令可以將用戶(hù)文本信息文件轉(zhuǎn)換為db數(shù)據(jù)庫(kù)并使用hash加密.
選項(xiàng)-T允許應(yīng)用程序能夠?qū)⑽谋疚募D(zhuǎn)譯載入進(jìn)數(shù)據(jù)庫(kù).由于我們之后是將虛擬用戶(hù)的信息以文件方式存儲(chǔ)在文件里的,為了讓Vsftpd這個(gè)應(yīng)用程序能夠通過(guò)文本來(lái)載入用戶(hù)數(shù)據(jù),必須要使用這個(gè)選項(xiàng).
指定了選項(xiàng)-T,那么一定要追加子選項(xiàng)-t ; 子選項(xiàng)-t,追加在在-T選項(xiàng)后,用來(lái)指定轉(zhuǎn)譯載入的數(shù)據(jù)庫(kù)類(lèi)型.hash就是使用hash碼加密.
-f參數(shù)后面接包含用戶(hù)名和密碼的文本文件,文件的內(nèi)容是:奇數(shù)行用戶(hù)名、偶數(shù)行密碼;
$ db_load -T -t hash -f /etc/vsftpd/ftpuser.txt /etc/vsftpd/vsftpd_login.db
$ chmod 600 /etc/vsftpd/vsftpd_login.db
如果要?jiǎng)h除掉一個(gè)虛擬用戶(hù),先在ftpuser.txt中刪除用戶(hù)對(duì)應(yīng)的用戶(hù)名和密碼,然后刪除vsftpd_login.db,重新運(yùn)行
db_load -T -t hash -f /etc/vsftpd/ftpuser.txt /etc/vsftpd/vsftpd_login.db
如果更改密碼,更改文件內(nèi)容后還需重新運(yùn)行db_load就可以,并重啟ftp服務(wù)使其生效.
如果要改變用戶(hù)的其它配置,只需修改用戶(hù)的配置文件.
$ vim /etc/pam.d/vsftpd.vu
將以下內(nèi)容加入到文件最前面(在后面加入無(wú)效)
auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
上一步建立的數(shù)據(jù)庫(kù)vsftpd_login在此處被使用,建立的虛擬用戶(hù)將采用PAM進(jìn)行驗(yàn)證,這是通過(guò)/etc/vsftpd/vsftpd.conf
文件中的語(yǔ)句pam_service_name=vsftpd.vu
來(lái)啟用的.
$ mkdir -p /etc/vsftpd/vsftpd_user_conf
$ vim /etc/vsftpd/vsftpd_user_conf/ftpupload
anon_world_readable_only=NO
write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_root=/home/ftpdata/
有時(shí)候可能需要開(kāi)啟VSftpd服務(wù)器之間的站點(diǎn)對(duì)傳功能,只需在主配置文件/etc/vsftpd/vsftpd.conf
里加入如下參數(shù)即可
pasv_promiscuous=YES
port_promiscuous=YES
說(shuō)明
port_promiscuous=YES|NO
默認(rèn)值為NO.為YES時(shí),取消PORT安全檢查.該檢查確保外出的數(shù)據(jù)只能連接到客戶(hù)端上.小心打開(kāi)此選項(xiàng).pasv_promiscuous=YES|NO
默認(rèn)值為NO.為YES時(shí),將關(guān)閉PASV模式的安全檢查.該檢查確保數(shù)據(jù)連接和控制連接是來(lái)自同一個(gè)IP地址.小心打開(kāi)此選項(xiàng).此選項(xiàng)唯一合理的用法是存在于由安全隧道方案構(gòu)成的組織中.
由于取消了數(shù)據(jù)包的安全檢查,允許數(shù)據(jù)流向非客戶(hù)端,所以站點(diǎn)對(duì)傳成功.
配置修改完成后,重啟vsftpd服務(wù)生效
$ /etc/init.d/vsftpd restart
VSftpd與log有關(guān)的選項(xiàng)
vsftpd_log_file
xferlog_enable
xferlog_std_format
xferlog_file
dual_log_enable
syslog_enable
log_ftp_protocol
no_log_lock
這里主要要到下面幾個(gè)參數(shù)控制
log_ftp_protocol
如果啟用, 假若選項(xiàng)xferlog_std_format沒(méi)有啟用, 所有的FTP請(qǐng)求和應(yīng)答都會(huì)被記錄. 此選項(xiàng)將對(duì)調(diào)試很有用.
默認(rèn): YESdual_log_enable
如果啟用, 將生成兩個(gè)相似的日志文件, 默認(rèn)在/var/log/xferlog和/var/log/vsftpd.log目錄下. 前者是wu-ftpd類(lèi)型的傳輸日志, 可以用于標(biāo)準(zhǔn)工具分析. 后者是vsftpd自己類(lèi)型的日志.xferlog_enable
如果啟用, 將會(huì)維護(hù)一個(gè)日志文件, 用于詳細(xì)記錄上載和下載. 默認(rèn)情況下, 這個(gè)日志文件是/var/log/vsftpd.log. 但是也可以通過(guò)配置文件中的vsftpd_log_file選項(xiàng)來(lái)指定.
默認(rèn): NO(但是在示例設(shè)置中啟用了這個(gè)選項(xiàng))xferlog_std_format
如果啟用, 傳輸日志文件將以標(biāo)準(zhǔn)xferlog的格式書(shū)寫(xiě), 如同wu-ftpd一樣. 這可以用于重新使用傳輸統(tǒng)計(jì)生成器. 然而, 默認(rèn)格式更注重可讀性. 此格式的日志文件默認(rèn)為/var/log/xferlog, 但是您也可以通過(guò)xferlog_file選項(xiàng)來(lái)設(shè)定.
默認(rèn): NOxferlog_file
xferlog 日志文件所在位置,默認(rèn)為/var/log/xferlog.vsftpd_log_file
指定VSFTPd日志文件位置,默認(rèn)為/var/log/vsftpd.log,xferlog_enable的默認(rèn)值為no(VSFTPd提供的配置文件模版將其值改為了yes),dual_log_enable的默認(rèn)值也為no,就是說(shuō)默認(rèn)情況下VSFTPd是不記錄日志的.我們也可以將日志信息寫(xiě)入系統(tǒng)日志/var/log/messages中,使用如下參數(shù):syslog_enable=yes/no
將xferlog_file前面的#號(hào)對(duì)掉,也就是把VSftpd的Log功能打開(kāi),這樣我們就能在/var/log目錄下查看xferlog.這是VSftpd日志功能,這對(duì)于我們來(lái)說(shuō)是極為重要的.
##################log settings###################
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/xferlog
#
#log in two files /var/log/xferlog and /var/log/vsftpd.log
dual_log_enable=YES
vsftpd_log_file=/var/log/vsftpd.log
#log time setting
use_localtime=YES
#
###################end of log####################
VSftpd對(duì)同一個(gè)IP地址的同時(shí)連接數(shù)量默認(rèn)是沒(méi)有限制的.在VSftpd中的max_per_ip選項(xiàng)是0,代表沒(méi)有限制.
如果你想限制同一個(gè)IP地址的同時(shí)連接數(shù)量,你需要修改/etc/vsftpd/vsftpd.conf
文件.以下是一個(gè)例子
pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES
max_per_ip=2
在這個(gè)例子中,每一個(gè)主機(jī)最多只能有兩個(gè)連接.修改vsftpd.conf之后,你需要重啟VSftpd來(lái)讓它生效.
一旦達(dá)到最大連接數(shù),同一個(gè)主機(jī)下對(duì)這個(gè)FTP服務(wù)器的其他連接會(huì)出現(xiàn)以下的錯(cuò)誤信息.
421 There are too many connections from your internet address.
通過(guò)/etc/hosts.allow
定義允許的來(lái)源地址,/etc/hosts.deny
定義拒絕的來(lái)源地址.
配置示例
/etc/hosts.allow
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
vsftpd: 123.103.47.0/255.255.255.0 218.240.63.0/255.255.255.0 59.46.172.0/255.255.255.0 10.0.0.0/255.0.0.0 60.2.80.0/255.255.255.0 218.249.230.0/255.255.255.0 160.10.0.0/255.255.0.0 218.246.69.0/255.255.255.0 125.35.3.0/255.255.255.0 : allow
/etc/hosts.deny
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
vsftpd : ALL : DENY
將tcp_wrappers=yes添加至/etc/vsftpd/vsftpd.conf
中
$ vi /etc/vsftpd/vsftpd.conf
tcp_wrappers=YES
重新啟動(dòng)VSftpd
$ service vsftpd restart
Shutting down vsftpd: OK ]
Starting vsftpd for vsftpd: OK ]
如果配置中出現(xiàn)問(wèn)題,請(qǐng)從以下幾方面檢查
setsebool -P ftp_home_dir=1
.http://www.google.com
http://www.ha97.com/4113.html
http://www.cnblogs.com/sztsian/archive/2011/08/23/2204102.html
文:Mike
文章出處:運(yùn)維之美(微信公眾號(hào)ID:Hi-Linux)
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/4468.html