Article Title: vsftp configuration Daquan --- ultra full version. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
I. Preface
Vsftp (Very Secure FTP) is a Secure, fast, and stable FTP server in Unix/Linux. It has been used by many large websites, such as ftp.redhat.com, ftp.kde.org, and ftp.gnome.org.. There are three methods to implement Vsftpd.
1. Anonymous user: by default, the system only provides anonymous user access.
2. Local User form: the user name in/etc/passwd is used as the authentication method
3. Virtual User: You can save the user name and password in a database file or database server. Compared with local FTP users, virtual users are only private users of the FTP server. Virtual users can only access the resources provided by the FTP server, which greatly enhances the security of the system. Compared with anonymous users, a virtual user requires a user name and password to obtain files on the FTP server. This increases the manageability of users and downloads. For FTP sites that require the download service, but do not require everyone to download them anonymously, you need to manage the download users and take into account host security and convenient management, virtual users are an excellent solution.
2. Get the latest Vsftp Program
Official download of Vsftp: forbidden. Assume that we have downloaded the vsftpd-2.0.3.tar.gz file to the/home/xuchen directory on the server.
[Copy to clipboard] [-] CODE:
# Cd/home/xuchen
# Tar xzvf vsftpd-2.0.3.tar.gz // extract Program
# Cd vsftpd-2.0.3
3. Implementation in three ways
1. Implement Anonymous Users
# Vi builddefs. h \ edit the builddefs. h file. The file content is as follows:
# Ifndef VSF_BUILDDEFS_H
# Define VSF_BUILDDEFS_H
# Undef VSF_BUILD_TCPWRAPPERS
# Define VSF_BUILD_PAM
# Undef VSF_BUILD_SSL
# Endif/* VSF_BUILDDEFS_H */
Change undef to define. tcp_wrappers is supported. PAM Authentication and SSL are supported.
# Make // compile with make directly in the vsftpd-2.0.3
# Ls-l vsftpd
-Rwxr-xr-x 1 root 86088 Jun 6 vsftpd // the executable program has been compiled successfully.
Create necessary accounts and directories:
# Useradd nobody // your system may already have this account, so you do not need to create
# Mkdir/usr/share/empty // This directory may already exist in your system, so you do not need to create
# Mkdir/var/ftp // This directory may already exist in your system, so you do not need to create
# Useradd-d/var/ftp // This account may already exist in your system, so you do not need to create
# Chown root: root/var/ftp
# Chmod og-w/var/ftp
Remember, if you do not want a user to log on locally, you need to set the login SHELL to/sbin/nologin, for example, the above nobody and ftp are set to/sbin/nologin.
Install the vsftp configuration file, executable program, man, and so on:
# Install-m 755 vsftpd/usr/local/sbin/vsftpd-ano
# Install-m 644 vsftpd.8/usr/share/man/man8
# Install-m 644 vsftpd. conf.5/usr/share/man/man5
# Install-m 644 vsftpd. conf/etc/vsftpd-ano.conf
In this way, the installation is complete, so we start to perform simple configuration.
# Vi/etc/vsftpd-ano.conf, add the following three lines to the file
Listen = YES
Listen_port = 21
Tcp_wrappers = YES
Anon_root =/var/ftp // set the anonymous user's local directory, which must be the same as the ftp user directory
Listen = YES means to start vsftpd with standalone, instead of controlling it with super daemon (xinetd) (standalone mode is recommended for vsftpd)
#/Usr/local/sbin/vsftpd-ano/etc/vsftpd-ano.conf & // start vsftpd later
Note: Do not set spaces for values in each line. Otherwise, an error will occur during startup. For example, if I add spaces after listen = YES, the following error occurs when I start it:
500 OOPS: bad bool value in config file for: listen
Test the established anonymous user method.
# Ftp 127.0.0.1
Connected to 127.0.0.1.
220 (vsFTPd 2.0.3)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (127.0.0.1: root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
Ftp>; pwd
257 usd "/"
Ftp>; quit
221 Goodbye.
#
OK, It is finished. very nice.
Advanced Configuration
A careful friend may have seen that we only added four lines to the default configuration file to achieve FTP connections (which also proves the ease of use of vsftpd), so let's upload a file, ah !! Transmission failed (SEE)
Why? Because vsftpd is for security purposes, the/var/ftp directory cannot open all permissions, so we need to create a directory pub, of course, we still need to modify the configuration file.
# Mkdir/var/ftp/pub
# Chmod-R 777/var/ftp/pub
To facilitate the test, we first create a script named kill-ano to kill the FTP program.
#! /Bin/bash
A = '/bin/ps-A | grep vsftpd-ano | awk' {print $1 }''
Kill-9 $
Now let's look at my anonymous server configuration file.
Anonymous_enable = YES // anonymous access is allowed, which is required by the anonymous server.
Write_enable = YES // global configuration writable
No_anon_password = YES // no password is asked when an anonymous user logs in
Anon_umask = 077 // The permission for uploading files by anonymous users is-rw ----
Anon_upload_enable = YES // allows anonymous users to upload files
Anon_mkdir_write_enable = YES // allows anonymous users to create directories
Anon_other_write_enable = YES // Anonymous Users are allowed to create directories and upload files, such as renaming and deleting.
Dirmessage_enable = YES // when the user converts the directory, the. message Information under the directory is displayed.
Xferlog_enable = YES // records all uploaded and downloaded user information
Xferlog_file =/var/log/vsftpd. log // upload and download information to/var/log/vsftpd. log
Xferlog_std_format = YES // The standard xferlog format is used for logs.
Idle_session_timeout = 600 // The client is automatically kicked out by the server if it exceeds S.
Data_connection_timeout = 120 // when the data is transmitted for over s, no action is triggered by the server
Chown_uploads = YES
Chown_username = daemon // owner of the uploaded file
Ftpd_banner = Welcome to d-1701.com FTP service. // FTP Welcome information
Anon_max_rate = 80000 // The download speed of anonymous users is 80 KBytes/s.
Check_shell = NO // SHELL not detected
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]... Next page>