Building FTP server notes with vsftpd in Ubuntu

Source: Internet
Author: User
There are many articles on using vsftpd to build FTP in linux on the Internet, most of which are similar. There are also the best vsftpd configuration tutorials & rdquo;, and the most detailed vsftpd configuration files & rdquo; and & ldquo; vsftpd entry-level topics & rdquo; and other articles with such names, but I don't know if you have the same experience, but it is difficult to make a success after reading the article, and there will always be various errors. In addition, there are some configurations described in

There are many articles on using vsftpd to build FTP in linux on the Internet, most of which are similar. There are also articles with such names as "I have seen the best vsftpd configuration tutorial", "the most detailed vsftpd configuration file in History", and "vsftpd entry topics". However, I don't know if everyone has the same experience. It is difficult to make a success after reading the article, and there will always be various errors. Moreover, some of the configuration items mentioned in this section cannot be really understood, such as: chroot_local_user, chroot_list_enable, and chroot_list_file. Can you simply design vsftpd, it's so obscure!

In the past two days, the FTP server has become a big master, but fortunately, a usable FTP server has been established. It will be a waste of time to continue using it later. Let's record some key points and hope to have a little reference value for everyone.

First, the following comprehensive information is provided:

  • Four Advanced configurations for vsftpd servers: http://www.linuxidc.com/Linux/2013-09/90565.htm
  • VsFTPd configuration Tutorial: http://www.linuxidc.com/Linux/2013-09/90562.htm

The former is indeed a comprehensive introduction, but many of its contents belong to high-level topics. It is really difficult for novice users to fully understand it. If the requirements are not met, the latter will be appropriate. It is more suitable for entry-level cainiao (think of me like this) reference. I just built it by referring to this article. In addition, there is a: http://www.linuxidc.com/Linux/2013-09/90564.htm. The following describes how to install the Configuration:

1. Install vsftpd

In this step, run sudo apt-get install vsftpd directly. After the installation is complete, you can log on to fpt: // ip directly under the default configuration. Here, anonymous logon is used, and you do not need to enter the user name and password. In fact, after vsftpd is installed, an ftp account is created. You can view the/etc/passwd file and find the Home Directory of the ftp account in/srv/ftp, therefore, after Anonymous logon, it is actually in/srv/ftp. You can test the file in this directory. You can also test whether you have the permission to download, upload, delete, and create directories during Anonymous logon.

2. Prepare an ftp SYSTEM account

User ftp is the default user for anonymous logon. If you need to log on to ftp through user authentication, you can set the "Allow Local User" mode in the configuration file, you can log on to ftp through an account in the Ubuntu system. Therefore, a new user is created here to log on to ftp. Use the following command to create a new user ftpuser, and specify shell in-s (the specified/sbin/nologin is actually an invalid shell, which makes the user unable to log on from the system ), -m is used to create a home directory (I .e./home/ftpuser)

Useradd vsftpd-s/sbin/nologin-m ftpuser

3. Configuration File

About the configuration file (/etc/vsftpd. conf) I will not describe it in detail here. Refer to the above article "vsftpd configuration tutorial" for configuration. After the configuration is complete, it may fail. The configuration items will be explained later for the problems that arise.

Note that if the log function is enabled, that is, xferlog_enable = YES, the log file option is xferlog_file =/var/log/vsftpd. log. If this option is not modified, the default log file is/var/log/vsftpd. log, the vsftpd configuration tutorial emphasizes that ftpuser has the write permission on the file. If you are not familiar with the permission or are afraid of trouble, you can directly grant 666 permissions, that is: chmod 666/var/log/vsftpd. log.

4. Do not switch to other directories outside the home directory

When you log on to the FTP server as an ftpuser user, the/home/ftpuser directory is entered by default. However, you can click "upper-level directory" to enter the upper-level directory, upper-level directory, or all other directories, this is obviously insecure. You need to modify the configuration to disable this function.

The article http://www.linuxidc.com/Linux/2013-09/90560.htm and http://www.linuxidc.com/Linux/2013-09/90563.htm are talking about the way to solve the problem, and basically consistent. In fact, it is to configure three options: chroot_local_user, chroot_list_enable, and chroot_list_file. These three options are used with each other, which is the most difficult to understand and most troublesome, it is also the reason why I have previously questioned the design so obscure.

The first article is relatively clear. The following is a summary:

First, chroot_list_enable is easy to understand, that is, whether to enable the chroot_list_file configuration file. If YES, it indicates whether the file configured for chroot_list_file takes effect; otherwise, it does not take effect;

Second, chroot_list_file is also simple. A file path is configured. The default value is/etc/vsftpd. chroot_list. Some account names are entered in this file. However, the meaning of these accounts is not fixed, and it is related to the configuration item chroot_local_user. Description in the next line;

Third, if the value of chroot_local_user is YES, all users * cannot * switch to a directory other than the main directory,! Except for the users listed in the chroot_list_file configuration file. If the value of chroot_local_user is NO, all users can ** switch to a directory other than the home directory,! Except for the users listed in the chroot_list_file configuration file. It can also be understood as the "exceptions" listed by chroot_list_file.

Explained the meaning of the three configuration items, it is easy to do, such as the article http://blog.csdn.net/fafa211/article/details/8095439? Reload. To restrict all users from switching to a directory other than the main directory, you only need to configure one item: chroot_local_user = YES, And chroot_list_file must be empty.

5. Solve the error "500 OOPS: vsftpd: refusing to run with writable root inside chroot ()"

After the configuration is complete in the previous step, log on to the browser. If there is no accident, the error "500 OOPS: vsftpd: refusing to run with writable root inside chroot ()" will occur ()". With regard to this error, I used to remove the writable attribute of the user's home directory, create a new directory data in it, and put the file to be uploaded into data, as shown below:

# Sudo chmod a-w/home/ftpuser

# Sudo mkdir/home/ftpuser/data

6. Enable and disable write permission

This configuration is also very important. The Write Permission indicates whether the login user can upload files, create directories, delete files or directories. Therefore, you must carefully consider this permission when setting up FTP, if the FTP server is only available for downloading, you can disable the write permission, which is more secure.

It is easy to configure this permission, that is, the write_enable configuration item in the configuration file (/etc/vsftpd. conf). Set it to YES to enable the write permission, and set it to NO to disable the write permission.

[Summary]

(1) other configuration items, such as connection timeout, maximum number of connections, download speed limit, and welcome slogans, do not need to be introduced. You can simply check the information and understand them. All of the above are key configurations. With these configurations, you can ensure that your FTP server is running. You need to figure out the specific configuration.

(2) advanced topics, such as virtual users, coexistence of multiple users, and configuration of different permissions for multiple users. I will not introduce them here. In fact, I don't know ^_^! As I said before, I am also a beginner! In addition, these advanced themes need to be used and gradually become familiar with them before they can be understood. Come on!

 

Recommended reading:

 

Ubuntu practical and simple FTP erection http://www.linuxidc.com/Linux/2012-02/55346.htm

 

Set up FTP server and Apache server http://www.linuxidc.com/Linux/2011-04/35295.htm on Ubuntu

 

Install LAMP \ vsftpd \ Webmin \ phpMyAdmin service and set http://www.linuxidc.com/Linux/2013-06/86250.htm in Ubuntu 13.04

 

Simple case http://www.linuxidc.com/Linux/2013-04/82300.htm for anonymous uploading of SeLinux and vsftpd on RHEL6 Platform

 

Linux vsftpd source code installation http://www.linuxidc.com/Linux/2013-03/81475.htm

 

Case study of vsftpd Security Configuration http://www.linuxidc.com/Linux/2012-12/76501.htm

 

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.