歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 10.04使用vsftp初級體會

Ubuntu 10.04使用vsftp初級體會

日期:2017/2/28 16:30:23   编辑:Linux教程
最近在Ubuntu 10.04下玩了幾天vsftp,主要目的是實現兩台計算機的共享的,samba太老了,現在都不用這個,還是vsftp好,簡單又安全,下面記錄一下折騰這個的流程,以後再利用vsftp弄個高級點的ftp。以下操作,全是在root下進行。由於我技術有限,此文不是教程,僅作參考。

vsftp就是“非常安全的ftp”。

1.安裝

apt-get install vsftpd

為什麼會有一個d呢?呵呵,一般來說d表示系統服務進程,所以安裝的時候是vsftpd,這個在ssh等等中也是一樣的。

2.vsftpd的環境

1} vsftp安裝完成後會生成一個名字是ftp的賬戶,密碼ftp,可以在/etc/passwd中看到,一般來說這時候可以建立一個ftp文件,自己設置的是/home/ftp,最好再把ftp改成777的權限。

2} /etc/vsftpd.conf 主要就是vsftpd的配置文件,相當重要的一個東西。

3} /etc/pam.d/vsftpd 與pam組相關的文件,pam組主要用來進行身份認證和抵御功能,初期沒必要太了解這個。

4} /etc/ftpusers 這個主要是和上面的搭配,設定拒絕登陸的賬號,一般都是本機上的賬號,vim它,會發現root在列,這也解釋了為啥子我一開始在root下老登陸不進去ftp。

5} finger ftp,這個命令主要是查看ftp這個用戶的一些信息,包括登陸時間,默認家目錄等等,其中,ftp這個用戶的家目錄會作為匿名登陸用戶顯示的目錄(即是匿名用戶的根目錄)。

3.一些重要的概念以及操作

ftp localhost

這個的意思就是,以本地機器連入ftp,就是在你的Ubuntu上連入ftp啦,localhost實際上是指通過lookback接口向應用程序提供連結,localhost的IP是 127.0.0.1,你可以自己看成這個IP就是你自己電腦的IP地址,只不過是專門用來進行系統內部程序的通信用的。

chroot

change root diectry,root指的是根目錄,為什麼會有這個呢,因為一旦別人連入你的ftp,它可以向上級訪問目錄,也就是說可以訪問你的任何一個文件,這個是不好滴,所以利用chroot可以把連進來的用戶限制到一個目錄裡面操作,它能訪問這個文件夾裡的一切東西,但是就是不能跳出這個文件夾訪問上級目錄。這個chroot相當重要。

chown

這個是改變文件的所屬用戶組的命令,初級階段不太用的上,以後會說明。

4.自己環境下vsftp的功能,以及配置。下面主要說說自己的配置,順帶說明一些功能。

vsftp的功能:

允許匿名用戶登錄,登陸的目錄為/srv/ftp(也即是我finger ftp得到的ftp用戶家目錄,這個是vsftp默認的),匿名用戶只擁有下載權限,不具備上傳,新建文件夾等權限,並且被限制在/srv/ftp目錄下,不允許查看上級目錄(比如我的/ect /boot等目錄)。

允許本地用戶登錄,本地用戶就是指你Ubuntu機器上的用戶,比如root,ftp,xxx用戶等等,本地用戶擁有所有權限,進入的默認目錄是/home/ftp(所以上面說建一個這個目錄),並且可以訪問機器上的任何目錄。

開啟FTP的日志功能,記錄FTP的所有操作。在vsftpd.conf中很多配置是一環扣一環的,比如說如果write_enable沒有開啟,那麼設置upload=YES也是沒有用的。慢慢學習,就會知道一些。

下面是vsftpd.conf的內容。

# Example config file /etc/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.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=YES #都有注釋的,感覺沒必要記錄,就是讓vsftpd以standalone方式啟動,一般都如此。
#
# Run standalone with IPv6?
# Like the listen parameter, except vsftpd will listen on an IPv6 socket
# instead of an IPv4 one. This parameter and the listen parameter are mutually
# exclusive.
#listen_ipv6=YES
#
# Allow anonymous FTP? (Disabled by default)
anonymous_enable=YES #是否允許匿名用戶登錄
#
# Uncomment this to allow local users to log in.
local_enable=YES #是否允許本地用戶登錄,啥是本地用戶?上面有說到了。。。
#
# Uncomment (look up to dictionary) 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 #這個的意思是本地用戶上傳的文件權限,022=777 077=755。
#
# 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=NO #是否允許匿名用戶上傳
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=NO #是否允許匿名用戶創建文件夾
no_anon_password=YES #匿名用戶登錄時,忽略密碼檢查
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES #顯示文件夾信息,即是,一個用戶進入某一文件目錄時,會顯示你事先寫好的一些提示信息
#
# If enabled, vsftpd will display directory listings with the time
# in your local time zone. The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=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 #所有匿名用戶上傳的文件的所有者會變成“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.
# 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 #設定空閒連接時間,如果一個連結無操作,600秒後斷開
#
# 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 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編碼的方式
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=this is wc's ftp,which has been testing #歡迎信息
#
# 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 restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES #限制本地用戶的目錄,我沒有使用。
#
# 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_local_user為YES的話,那麼你開啟這個,在下面那個list文件中的用戶將不受chroot約束。
# (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
#
# Debian customization
#
# Some of vsftpd's settings don't fit the Debian filesystem layout by
# default. These settings are more Debian-friendly.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/private/vsftpd.pem
local_root=/home/ftp #本地用戶登錄時候進入的目錄
max_clients=100 #最多允許的客戶端

實際上說vsftp的配置還是比較復雜,而且功能很多,上面也沒有一一例舉完。

Copyright © Linux教程網 All Rights Reserved