搭建ftp环境
對(duì)于搭建ftp環(huán)境是新手最早要接觸的一個(gè)部分,在搭建之前,我看了很多資料搜索了很多關(guān)于這塊的配置和解說(shuō),大部分都是大同小異的,很多可能對(duì)于剛剛接觸的人來(lái)說(shuō)還是有一點(diǎn)點(diǎn)的難理解,但是在經(jīng)過(guò)自己的摸索和朋友的指導(dǎo)后,基本對(duì)這塊有了很多的認(rèn)識(shí)。(最重要的是:不知道就要多找多問(wèn))直接開(kāi)始說(shuō)吧
一般在各種linux的發(fā)行版中,默認(rèn)帶有的ftp軟件是vsftp,從各個(gè)linux發(fā)行版對(duì)vsftp的認(rèn)可可以看出,vsftp應(yīng)該是一款不錯(cuò)的ftp軟件。 (1)檢查vsftpd軟件是否安裝 使用如下命令可以檢測(cè)出是否安裝了vsftpd軟件,rpm -qa |grep vsftpd,我的linux自帶的就是vsftpd-2.2.2-6.el6.x86_64。 ????? 如果沒(méi)有安裝的話可以百度直接下載,只要網(wǎng)速給力就好,都不是很大!!(2)vsftpd軟件的使用
?
使用vsftpd軟件,主要包括如下幾個(gè)命令:
?
????????????????啟動(dòng)ftp:service vsftpd start
?
????????????????停止ftp:service vsftpd stop
?
????????????????重啟ftp:service vsftpd restart
或者使用帶有路徑的命令:
?
?
(3)vsftpd的配置
?
ftp的配置文件主要有三個(gè),在centos5.6中位于/etc/vsftpd/目錄下,分別是:
?
ftpusers????該文件用來(lái)指定那些用戶不能訪問(wèn)ftp服務(wù)器。
?
user_list???該文件用來(lái)指示的默認(rèn)賬戶在默認(rèn)情況下也不能訪問(wèn)ftp
?
vsftpd.conf???vsftpd的主配置文件
????(4)使用vi編輯vsftpd.conf文件
?1.vsftpd.conf文件說(shuō)明
# 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??//是否允許anonymous登錄FTP服務(wù)器,默認(rèn)是允許的.
#
# Uncomment this to allow local users to log in.
local_enable=YES?//是否允許本地用戶登錄FTP服務(wù)器,默認(rèn)是允許
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES??//是否允許用戶具有在FTP服務(wù)器文件中執(zhí)行寫(xiě)的權(quán)限,默認(rèn)是允許
#
# 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 //設(shè)置本地用戶的文件生成掩碼為022,默認(rèn)是077
#
# 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??//是否允許匿名賬戶在FTP服務(wù)器中創(chuàng)建目錄
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES //激活目錄信息,當(dāng)遠(yuǎn)程用戶更改目錄時(shí),將出現(xiàn)提示信息
#
# Activate logging of uploads/downloads.
xferlog_enable=YES??//啟用上傳和下載日志功能
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES???//啟用FTP數(shù)據(jù)端口的連接請(qǐng)求
#
# 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/vsftpd.log??//設(shè)置日志文件的文件名和存儲(chǔ)路徑,這是默認(rèn)的
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES//是否使用標(biāo)準(zhǔn)的ftpd xferlog日志文件格式
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600??//設(shè)置空閑的用戶會(huì)話中斷時(shí)間,默認(rèn)是10分鐘
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120//設(shè)置數(shù)據(jù)連接超時(shí)時(shí)間,默認(rèn)是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 turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command "SIZE /big/file" in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES?//是否允許使用ASCII格式來(lái)上傳和下載文件
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.//在FTP服務(wù)器中設(shè)置歡迎登錄的信息.
#
# 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?//如果希望用戶登錄后不能切換到自己目錄以外的其它目錄,需要設(shè)置該項(xiàng),如果設(shè)置chroot_list_enable=YES,那么只允許/etc/vsftpd.chroot_list中列出的用戶具有該功能.如果希望所有的本地用戶都執(zhí)行者chroot,可以增加一行:chroot_local_user=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
pam_service_name=vsftpd??//設(shè)置PAM認(rèn)證服務(wù)的配置文件名稱,該文件存放在/etc/pam.d/目錄下.
userlist_enable=YES?//用戶列表中的用戶是否允許登錄FTP服務(wù)器,默認(rèn)是不允許
#enable for standalone mode
listen=YES??//使vsftpd?處于獨(dú)立啟動(dòng)模式
tcp_wrappers=YES??//使用tcp_wrqppers作為主機(jī)訪問(wèn)控制方式
?
??????另外兩個(gè)文件是將用戶加入進(jìn)去后就不能登錄,這個(gè)按自己的要求去修改添加
??對(duì)于剛接觸這塊的時(shí)候可以不用修改上面的配置文件,不修改的話是匿名可以直接登入,不需要帳號(hào)和密碼,可以先試試(有的可能在web上登入不上,檢查下你的實(shí)體機(jī)和虛擬機(jī)的防火墻是否關(guān)閉,關(guān)閉后再測(cè)試)
??ftp://xxx.xxx.xx.xx
?
六、添加用戶? 以上是對(duì)于匿名登錄后的顯示結(jié)果,添加帳號(hào)首先要對(duì)vsftpd.conf 編輯 anonymous_enable=YES修改為anonymous_enable=NO ?不允許匿名用戶登錄 然后是添加用戶 useradd -d /home/test -g ftp test passwd test /etc/init.d/iptables stop ???? setenforce 0 ???????????????關(guān)閉selinux /etc/init.d/vsftpd stop? /etc/init.d/vsftpd start? cd /home/test/ cd /home/test ls echo "1" > 1.txt ??????????添加 1 文本文檔 (如果不行,請(qǐng)檢查防火墻,如果你用的是虛擬機(jī)先關(guān)閉:service iptables stop,之后也關(guān)閉物理機(jī)的防火墻) 基本上大致就是這樣,這也是自己的一段見(jiàn)解,每個(gè)人的安裝方式不一樣,如有不對(duì)的地方可隨時(shí)提出轉(zhuǎn)載于:https://www.cnblogs.com/L-H-R-X-hehe/p/3788399.html
總結(jié)
- 上一篇: 触摸事件练习 -- 手势解锁
- 下一篇: SQL Server报“GUID应包含带