Setting up the FTP server under Ubuntu14.04 -- locking the user directory to solve the problem of vsftpd: refusingtorunwithwritablerootinsidechroot () FTP server construction. What I want to achieve is: anonymous access is not allowed, because I don't want anyone to log on to my machine and get files, I need to lock a directory. Because at home, I need to download movies, Korean dramas, and other things to my daughter-in-law, my daughter-in-law will come to my machine to download,
Setting up an FTP server in Ubuntu 14.04 -- locking the user directory to solve vsftpd: refusing to run with writable root inside chroot ()
To build an FTP server, I need:
Anonymous access is not allowed, because my machine does not want anyone to log on and obtain files as needed,
I need to lock a directory, because at home, I need to download movies, Korean dramas, and other things for my daughter-in-law. The daughter-in-law will come to my machine to download them, but I don't want him to operate my things at will.
In case of deleting my configuration file, I would be miserable. (Let's Talk About Korean drama: My daughter-in-law asked me, you haven't seen Korean drama. How do you know it's not good? I said: I have never eaten it, but I know it is definitely not good !)
In addition, access from the local machine is required, because I want to perform some tests on FTP.
FTP users are not created separately. FTP users also use ubuntu Desktop Users for logon and operations,
I do not want FTP to start.
Now let's start the installation, which is very simple.
Sudo apt-get install vsftpd
It is estimated that the installation can be completed within 30 seconds.
Start configuration below:
First, back up the configuration file.
Linuxidc @ ubuntu:/etc/init $ cd/etc/
Linuxidc @ ubuntu:/etc $ sudo cp vsftpd. conf vsftpd. conf. old
The next step is to start the configuration,
We will address the following requirements:
1. Anonymous access is not allowed, because my machine does not want anyone to log on and obtain files as needed,
The configuration is as follows:
23 anonymous_enable = NO
2. You need to lock a directory, because at home, I need to download movies, Korean dramas, and other things to my daughter-in-law,
My daughter-in-law will come to my machine for download, but I don't want him to operate my stuff at will.
In case of deleting my configuration file, I am miserable.
The configuration is as follows:
152 local_root =/home/linuxidc/public/FTP shared files
Note: [FTP shared file] This folder is created by me.
In addition, access from the local machine is required, because I want to perform some tests on FTP.
The configuration is as follows:
26 local_enable = YES
FTP users are not created separately. FTP users also use ubuntu Desktop Users for logon and operations,
The configuration is as follows:
120 # chroot_local_user = YES
121 chroot_list_enable = YES
122 # (default follows)
123 chroot_list_file =/etc/vsftpd. chroot_list
The/etc/vsftpd. chroot_list file is required here. If not, create a new one:
Sudo gedit/etc/vsftpd. chroot_list
The content is as follows (for example, my desktop user name is linuxidc ):
Duoduo
It is actually writing your username
I do not want FTP to start. I will talk about it later!
Paste my configuration file.
# 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
#
# Run standalone with IPv6?
# Like the listen parameter, parameter t 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 = NO
#
# 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
#
# Default umask for local users is 077. You may wish to change this to 022,
# If your users CT 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
#
# Uncomment this if you want the anonymous FTP user to be able to create
# New directories.
# Anon_mkdir_write_enable = 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.
# 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
#
# If you want, you can arrange for uploaded anonymous files to be owned
# 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.
# 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
#
# 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
# Ftp server can use as a totally isolated and unprivileged user.
# Nopriv_user = ft1_cure
#
# Enable this and the server will recognize 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
# 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 linuxidc's 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 restrict local users to their home directories. See the FAQ
# 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
# Users to NOT chroot ().
# (Warning! Chroot 'ing can be very dangerous. If using chroot, make sure that
# The user does not have write access to the top level directory within
# Chroot)
# Chroot_local_user = YES
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
# 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
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout
# Default.
#
# This option shoshould be the name of a directory which is empty. Also,
# Directory shocould 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/certs/ssl-cert-snakeoil.pem
# This option specifies the location of the RSA key to use for SSL
# Encrypted connections.
Rsa_private_key_file =/etc/ssl/private/ssl-cert-snakeoil.key
#
Local_root =/home/linuxidc/public/FTP shared files
Now you can restart FTP.
Linuxidc @ ubuntu:/etc $ sudo service vsftpd restart
Vsftpd stop/waiting
Vsftpd start/running, process 303
OK. The configuration file is correct and FTP is started.
Access FTP directly below:
Linuxidc @ ubuntu:/etc $ ftp 127.0.0.1
Connected to 127.0.0.1.
Welcome to linuxidc's FTP service.
Name (127.0.0.1: linuxidc): duoduo
Please specify the password.
Password:
OOPS: vsftpd: refusing to run with writable root inside chroot ()
Login failed.
Service not available, remote server has closed connection
Ftp>
A 500 error was reported.
Vsftpd: refusing to run with writable root inside chroot ()
. In fact, special instructions are needed here, because
120 # chroot_local_user = YES
121 chroot_list_enable = YES
122 # (default follows)
123 chroot_list_file =/etc/vsftpd. chroot_list
We use
Chroot_list_enable = YES and chroot_list_file =/etc/vsftpd. chroot_list are used together, so that only users configured in vsftpd. chroot_list can log on to FTP.
A special requirement for this configuration is that the user configured in vsftpd. chroot_list cannot have the write permission for the Directory configured in local_root!
That is, the/home/linuxidc/public/FTP Shared File Folder does not allow users to write to linuxidc,
We can do this for the sake of convenience:
Sudo chown-R root: root/home/linuxidc/public/FTP shared file/
In this way, the linuxidc user has no write permission for/home/linuxidc/public/FTP shared files,
Restart FTP and log on again:
Linuxidc @ ubuntu:/etc $ ftp 127.0.0.1
Connected to 127.0.0.1.
Welcome to linuxidc's FTP service.
Name (127.0.0.1: linuxidc): duoduo
Please specify the password.
Password:
Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
Ftp>
OK, FTP is ready. You can log on.
However, the operation of sudo chown-R root: root/home/linuxidc/public/FTP shared file/also brings a lot of trouble. The FTP shared file cannot be copied or pasted at will when I log on to my desktop. However, I still need to ensure that the IDC user cannot write the [FTP shared file] folder. What should I do?
It's actually very simple,
Cd/home/linuxidc/public/FTP shared files
Sudo mkdir FTPFILES
Sudo chown-R linuxidc: duoduo FTPFILES
In this way, the FTP shared file folder cannot be written by the linuxidc user, but the duoduo user can operate the file at any time when logging on to the desktop, but the random range is within the FTPFILES folder.
In this way, the basic FTP service is basically set up.
By the way, I forgot a bit. That is, do not let the FTP service start up. The procedure is as follows:
Linuxidc @ ubuntu:/etc/init $ cd/etc/init/
Linuxidc @ ubuntu:/etc/init $ sudo cp vsftpd. conf vsftpd. conf. old
Edit configuration file
Sudo gedit/etc/init/vsftpd. conf
Set # start on runlevel [2345] or net-device-up IFACE! = Lo is changed to start on runlevel [345] as follows:
# Start on runlevel [2345] or net-device-up IFACE! = Lo
Start on runlevel [345]
Stop on runlevel [! 2345]
The restart of the FTP system is complete.
We recommend that you check the following information: chroot_local_user chroot_list_enable = YES chroot_list_file =/etc/vsftpd. chroot_list. The configuration is flexible.
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
CentOS 7 installation configuration FTP server http://www.linuxidc.com/Linux/2014-11/109233.htm
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
Install and configure the FTP server vsftpd in openSUSE 13.2/13.1Http://www.linuxidc.com/Linux/2014-12/110070.htm
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2
This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-01/111970.htm