vsftpd的配置

FTP:安裝包是vsftpd-version (very secure FTP daemon)

,用於文件傳輸。一般用於局域網。

服務器IP:192.168.1.31

客戶端IP:192.168.1.32

用戶:1、匿名用戶ftp

           2、普通用戶a1,a2

           3、虛擬用戶

 

wKiom1OlU2-QdKTaAADkYdHMt1A495.jpg

關閉selinux後,普通用戶就可以登錄了。

 

wKiom1OlU6yD073MAAECVRytPPE576.jpg

普通用戶登錄後,只是在自己的家目錄下,可以隨意到系統的其他目錄下。

 

以下是配置文檔配置說明

[root@www vsftpd]# pwd

/etc/vsftpd

[root@www vsftpd]# vim 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  //匿名用戶登錄開啓,ftp用戶可以登錄

#

# 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  //上傳文件權限,只對本地用戶生效


例如:

客戶端驗證
[root@localhost ~]# lftp -l [email protected]   lftp登錄

lftp [email protected]:~> put /etc/inittab 

884 bytes transferred     

 

 

#

# 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  //是否允許匿名用戶有上傳權限

 

例如:

服務器端:

[root@www ftp]# ls

inittab  pub  upload

[root@www ftp]# setfacl -m u:ftp:rwx upload/

lftp 192.168.1.31:/upload> put /etc/inittab 

884 bytes transferred

 

lftp 192.168.1.31:/upload> help  //幫助命令

    !<shell-command>                     (commands)

    alias [<name> [<value>]]             bookmark [SUBCMD]

    cache [SUBCMD]                       cat [-b] <files>

    cd <rdir>                            chmod [OPTS] mode file...

    close [-a]                           [re]cls [opts] [path/][pattern]

    debug [<level>|off] [-o <file>]      du [options] <dirs>

    exit [<code>|bg]                     get [OPTS] <rfile> [-o <lfile>]

    glob [OPTS] <cmd> <args>             help [<cmd>]

    history -w file|-r file|-c|-l [cnt]  jobs [-v]

    kill all|<job_no>                    lcd <ldir>

    lftp [OPTS] <site>                   ls [<args>]

    mget [OPTS] <files>                  mirror [OPTS] [remote [local]]

    mkdir [-p] <dirs>                    module name [args]

    more <files>                         mput [OPTS] <files>

    mrm <files>                          mv <file1> <file2>

    [re]nlist [<args>]                   open [OPTS] <site>

    pget [OPTS] <rfile> [-o <lfile>]     put [OPTS] <lfile> [-o <rfile>]

    pwd [-p]                             queue [OPTS] [<cmd>]

    quote <cmd>                          repeat [OPTS] [delay] [command]

    rm [-r] [-f] <files>                 rmdir [-f] <dirs>

    scache [<session_no>]                set [OPT] [<var> [<val>]]

    site <site_cmd>                      source <file>

    torrent [-O <dir>] <file>            user <user|URL> [<pass>]

    version                              wait [<jobno>]

    zcat <files>                         zmore <files>

 

#

# Uncomment this if you want the anonymous FTP user to be able to create

# new directories.

anon_mkdir_write_enable=YES  //創建目錄的權限


anon_other_write_enable=YES  //其他權限


例如:lftp 192.168.1.31:/upload> rmdir test/


#

# Activate directory messages - messages given to remote users when they

# go into a certain directory.

dirmessage_enable=YES //每切換一個目錄,出現歡迎信息

例如:

[root@www upload]# cat .message 

-----welcom to upload

--thith you ----

 

 

ftp> cd upload

250------welcom to upload

250---thith you ----

250 Directory successfully changed.  //顯示了編輯的文件信息。


#

# 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/vsftpd.log  //傳輸日誌文件在哪裏,


例如,查看日誌文件

[root@www log]# cat vsftpd.log 

Thu Jun 19 22:01:16 2014 1 192.168.1.32 0 /fstab b _ i a lftp@ ftp 0 * i

Thu Jun 19 22:01:30 2014 1 192.168.1.32 899 /upload/fstab b _ i a lftp@ ftp 0 * c




#

# 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_local_user=YES  //鎖定用戶於家目錄中


chroot: 禁錮用戶於其家目錄中,實現方式有兩種:

1、禁錮所有用戶:

chroot_local_user=YES

2、禁錮指定用戶,黑名單 

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list 

3、不禁錮指定用戶,白名單

chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list 

 

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

#

# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6

# sockets, 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     //pam文件,

這個文件,

[root@www vsftpd]# vim /etc/pam.d/vsftpd 


userlist_enable=YES

ftpusers  user_list  這兩個文件是限制用戶登錄的

userlist_deny=NO //當有這項的時候,user_list中的用戶,就可以登錄ftp

user_list:ftp用戶白名單和黑名單:

1、白名單:

userlist_enable=YES

userlist_deny=NO

2、黑名單:默認即是

userlist_enable=YES

userlist_deny=YES

 

tcp_wrappers=YES


傳輸速率限定,默認單位爲字節:

anon_max_rate=100000

local_max_rate=2000000



 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章