搭建ftp环境
對于搭建ftp環境是新手最早要接觸的一個部分,在搭建之前,我看了很多資料搜索了很多關于這塊的配置和解說,大部分都是大同小異的,很多可能對于剛剛接觸的人來說還是有一點點的難理解,但是在經過自己的摸索和朋友的指導后,基本對這塊有了很多的認識。(最重要的是:不知道就要多找多問)直接開始說吧
一般在各種linux的發行版中,默認帶有的ftp軟件是vsftp,從各個linux發行版對vsftp的認可可以看出,vsftp應該是一款不錯的ftp軟件。 (1)檢查vsftpd軟件是否安裝 使用如下命令可以檢測出是否安裝了vsftpd軟件,rpm -qa |grep vsftpd,我的linux自帶的就是vsftpd-2.2.2-6.el6.x86_64。 ????? 如果沒有安裝的話可以百度直接下載,只要網速給力就好,都不是很大!!(2)vsftpd軟件的使用
?
使用vsftpd軟件,主要包括如下幾個命令:
?
????????????????啟動ftp:service vsftpd start
?
????????????????停止ftp:service vsftpd stop
?
????????????????重啟ftp:service vsftpd restart
或者使用帶有路徑的命令:
?
?
(3)vsftpd的配置
?
ftp的配置文件主要有三個,在centos5.6中位于/etc/vsftpd/目錄下,分別是:
?
ftpusers????該文件用來指定那些用戶不能訪問ftp服務器。
?
user_list???該文件用來指示的默認賬戶在默認情況下也不能訪問ftp
?
vsftpd.conf???vsftpd的主配置文件
????(4)使用vi編輯vsftpd.conf文件
?1.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??//是否允許anonymous登錄FTP服務器,默認是允許的.
#
# Uncomment this to allow local users to log in.
local_enable=YES?//是否允許本地用戶登錄FTP服務器,默認是允許
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES??//是否允許用戶具有在FTP服務器文件中執行寫的權限,默認是允許
#
# 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 //設置本地用戶的文件生成掩碼為022,默認是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服務器中創建目錄
#
# 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???//啟用FTP數據端口的連接請求
#
# 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??//設置日志文件的文件名和存儲路徑,這是默認的
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES//是否使用標準的ftpd xferlog日志文件格式
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600??//設置空閑的用戶會話中斷時間,默認是10分鐘
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120//設置數據連接超時時間,默認是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格式來上傳和下載文件
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.//在FTP服務器中設置歡迎登錄的信息.
#
# 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?//如果希望用戶登錄后不能切換到自己目錄以外的其它目錄,需要設置該項,如果設置chroot_list_enable=YES,那么只允許/etc/vsftpd.chroot_list中列出的用戶具有該功能.如果希望所有的本地用戶都執行者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??//設置PAM認證服務的配置文件名稱,該文件存放在/etc/pam.d/目錄下.
userlist_enable=YES?//用戶列表中的用戶是否允許登錄FTP服務器,默認是不允許
#enable for standalone mode
listen=YES??//使vsftpd?處于獨立啟動模式
tcp_wrappers=YES??//使用tcp_wrqppers作為主機訪問控制方式
?
??????另外兩個文件是將用戶加入進去后就不能登錄,這個按自己的要求去修改添加
??對于剛接觸這塊的時候可以不用修改上面的配置文件,不修改的話是匿名可以直接登入,不需要帳號和密碼,可以先試試(有的可能在web上登入不上,檢查下你的實體機和虛擬機的防火墻是否關閉,關閉后再測試)
??ftp://xxx.xxx.xx.xx
?
六、添加用戶? 以上是對于匿名登錄后的顯示結果,添加帳號首先要對vsftpd.conf 編輯 anonymous_enable=YES修改為anonymous_enable=NO ?不允許匿名用戶登錄 然后是添加用戶 useradd -d /home/test -g ftp test passwd test /etc/init.d/iptables stop ???? setenforce 0 ???????????????關閉selinux /etc/init.d/vsftpd stop? /etc/init.d/vsftpd start? cd /home/test/ cd /home/test ls echo "1" > 1.txt ??????????添加 1 文本文檔 (如果不行,請檢查防火墻,如果你用的是虛擬機先關閉:service iptables stop,之后也關閉物理機的防火墻) 基本上大致就是這樣,這也是自己的一段見解,每個人的安裝方式不一樣,如有不對的地方可隨時提出轉載于:https://www.cnblogs.com/L-H-R-X-hehe/p/3788399.html
總結
- 上一篇: 触摸事件练习 -- 手势解锁
- 下一篇: SQL Server报“GUID应包含带