<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux for Fun &#187; vsftpd</title>
	<atom:link href="http://linuxforfun.net/tag/vsftpd/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxforfun.net</link>
	<description>Just for Fun</description>
	<lastBuildDate>Tue, 12 Apr 2011 02:09:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Setup of VSFTPD &#8211; another approach</title>
		<link>http://linuxforfun.net/2008/04/15/vsftpd-virtual-users-another-approach/</link>
		<comments>http://linuxforfun.net/2008/04/15/vsftpd-virtual-users-another-approach/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 15:35:51 +0000</pubDate>
		<dc:creator>sandajian</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[virtual users]]></category>
		<category><![CDATA[vsftpd]]></category>

		<guid isPermaLink="false">http://linuxforfun.net/?p=15</guid>
		<description><![CDATA[If you are hosting several web sites, for security reason, you may want the webmasters to access their own files only. One of the good way is to give them FTP access by setup of VSFTPD virtual users and directories. In my last article, I described how to setup VSFTPD virtual users. In this article, [...]]]></description>
			<content:encoded><![CDATA[<p>If you are hosting several web sites, for security reason, you may want the webmasters to access their own files only.  One of the good way is to give them FTP access by setup of VSFTPD virtual users and directories.</p>
<p>In my <a href="http://linuxforfun.net/2008/04/05/vsftpd-virtual-users/" target="_blank">last article</a>, I described how to setup VSFTPD virtual users.  In this article, I will describe another approach to setup VSFTPD, it needs real users on the system.</p>
<p><strong>1. Installation of VSFTPD</strong></p>
<p>For Red Hat, CentOS and Fedora, you may install VSFTPD by the command</p>
<blockquote><p><code># yum install vsftpd</code></p></blockquote>
<p>For Debian and Ubuntu,</p>
<blockquote><p><code># apt-get install vsftpd</code></p></blockquote>
<p><span id="more-15"></span><strong>2. Virtual users and authentication</strong></p>
<p>We may create a real user account for each webmaster.  We will only give them FTP access to our server.</p>
<p>First, use `useradd&#8217; command to create user accounts.  Something to be specified are:</p>
<ul>
<li><strong>group</strong>: we may specify the group of users to the group HTTP server runs as.  In most cases, it is `apache&#8217; for Apache HTTP Server, it is `lighttpd&#8217; for lighttpd.</li>
<li><strong>home directory</strong>: we should also specify users&#8217; home directories to their virtual hosts&#8217; DocumentRoot.  We should also make these directories writable by HTTP server.</li>
<li><strong>login shell</strong>: in order to disallow normal login for these FTP users, we should specify their login shell to `/sbin/nologin&#8217;.</li>
</ul>
<p>For example:</p>
<blockquote><p><code># useradd -g apache -d /var/www/vhosts/mike -s /sbin/nologin mike<br />
# chmod g+w /var/www/vhosts/mike<br />
# passwd mike<br />
Changing password for user mike.<br />
New UNIX password:<br />
Retype new UNIX password:<br />
passwd: all authentication tokens updated successfully.</code></p></blockquote>
<p><strong>3. Configuration of VSFTPD</strong></p>
<p>Create a configuration file /etc/vsftpd/vsftpd-virtual.conf,</p>
<blockquote><p><code># disables anonymous FTP<br />
anonymous_enable=NO<br />
# enables non-anonymous FTP<br />
local_enable=YES<br />
# enables uploads and new directories<br />
write_enable=YES<br />
# authentication of virtual uses<br />
pam_service_name=login<br />
# the virtual user is restricted to the virtual FTP area<br />
chroot_local_user=YES<br />
# runs vsftpd in standalone mode<br />
listen=YES<br />
# listens on this port for incoming FTP connections<br />
listen_port=60021<br />
# the minimum port to allocate for PASV style data connections<br />
pasv_min_port=62222<br />
# the maximum port to allocate for PASV style data connections<br />
pasv_max_port=63333<br />
# controls whether PORT style data connections use port 20 (ftp-data)<br />
connect_from_port_20=YES<br />
# the umask for file creation<br />
local_umask=022</code></p></blockquote>
<p><strong>4. Start VSFTPD and test</strong><br />
Now we can start VSFTPD by the command:</p>
<blockquote><p><code># /usr/sbin/vsftpd /etc/vsftpd/vsftpd-virtual.conf</code></p></blockquote>
<p>and test the FTP access of a virtual user:</p>
<blockquote><p><code># lftp -u mike -p 60021 192.168.1.101</code></p></blockquote>
<p>The virtual user should have full access to his directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxforfun.net/2008/04/15/vsftpd-virtual-users-another-approach/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Setup of VSFTPD virtual users</title>
		<link>http://linuxforfun.net/2008/04/05/vsftpd-virtual-users/</link>
		<comments>http://linuxforfun.net/2008/04/05/vsftpd-virtual-users/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 08:12:53 +0000</pubDate>
		<dc:creator>sandajian</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[virtual users]]></category>
		<category><![CDATA[vsftpd]]></category>

		<guid isPermaLink="false">http://linuxforfun.net/2008/04/05/vsftpd-virtual-users/</guid>
		<description><![CDATA[If you are hosting several web sites, for security reason, you may want the webmasters to access their own files only. One of the good way is to give them FTP access by setup of VSFTPD virtual users and directories. This article describes how you can do that easily. (See also: Setup of VSFTPD virtual [...]]]></description>
			<content:encoded><![CDATA[<p>If you are hosting several web sites, for security reason, you may want the webmasters to access their own files only.  One of the good way is to give them FTP access by setup of VSFTPD virtual users and directories.  This article describes how you can do that easily.<br />
(See also: <a href="http://linuxforfun.net/2008/04/15/vsftpd-virtual-users-another-approach/">Setup of VSFTPD virtual users &#8211; another approach</a>)</p>
<p><strong>1. Installation of VSFTPD</strong></p>
<p>For Red Hat, CentOS and Fedora, you may install VSFTPD by the command</p>
<blockquote><p><code># yum install vsftpd</code></p></blockquote>
<p>For Debian and Ubuntu,</p>
<blockquote><p><code># apt-get install vsftpd</code></p></blockquote>
<p><span id="more-13"></span><strong>2. Virtual users and authentication</strong></p>
<p>We are going to use pam_userdb to authenticate the virtual users. This needs a username / password file in `db&#8217; format &#8211; a common database format.   We need `db_load&#8217; program.   For CentOS, Fedora, you may install the package `db4-utils&#8217;:</p>
<blockquote><p><code># yum install db4-utils</code></p></blockquote>
<p>For Ubuntu,</p>
<blockquote><p><code># apt-get install db4.2-util</code></p></blockquote>
<p>To create a `db&#8217; format file, first create a plain text file `virtual-users.txt&#8217; with the usernames and passwords on alternating lines:</p>
<blockquote><p><code>mary<br />
123456<br />
jack<br />
654321</code></p></blockquote>
<p>Then execute the following command to create the actual database:</p>
<blockquote><p><code># db_load -T -t hash -f virtual-users.txt /etc/vsftpd/virtual-users.db</code></p></blockquote>
<p>Now, create a PAM file /etc/pam.d/vsftpd-virtual which uses your database:</p>
<blockquote><p><code>auth required pam_userdb.so db=/etc/vsftpd/virtual-users<br />
account required pam_userdb.so db=/etc/vsftpd/virtual-users</code></p></blockquote>
<p><strong>3. Configuration of VSFTPD</strong></p>
<p>Create a configuration file /etc/vsftpd/vsftpd-virtual.conf,</p>
<blockquote><p><code># disables anonymous FTP<br />
anonymous_enable=NO<br />
# enables non-anonymous FTP<br />
local_enable=YES<br />
# activates virtual users<br />
guest_enable=YES<br />
# virtual users to use local privs, not anon privs<br />
virtual_use_local_privs=YES<br />
# enables uploads and new directories<br />
write_enable=YES<br />
# the PAM file used by authentication of virtual uses<br />
pam_service_name=vsftpd-virtual<br />
# in conjunction with 'local_root',<br />
# specifies a home directory for each virtual user<br />
user_sub_token=$USER<br />
local_root=/var/www/virtual/$USER<br />
# the virtual user is restricted to the virtual FTP area<br />
chroot_local_user=YES<br />
# hides the FTP server user IDs and just display "ftp" in directory listings<br />
hide_ids=YES<br />
# runs vsftpd in standalone mode<br />
listen=YES<br />
# listens on this port for incoming FTP connections<br />
listen_port=60021<br />
# the minimum port to allocate for PASV style data connections<br />
pasv_min_port=62222<br />
# the maximum port to allocate for PASV style data connections<br />
pasv_max_port=63333<br />
# controls whether PORT style data connections use port 20 (ftp-data)<br />
connect_from_port_20=YES<br />
# the umask for file creation<br />
local_umask=022</code></p></blockquote>
<p><strong>4. Creation of home directories</strong></p>
<p>Create each user&#8217;s home directory in /var/www/virtual, and change the owner of the directory to the user `ftp&#8217;:</p>
<blockquote><p><code># mkdir /var/www/virtual/mary<br />
# chown ftp:ftp /var/www/virtual/mary</code></p></blockquote>
<p><strong>5. Startup of VSFTPD and test</strong><br />
Now we can start VSFTPD by the command:</p>
<blockquote><p><code># /usr/sbin/vsftpd /etc/vsftpd/vsftpd-virtual.conf</code></p></blockquote>
<p>and test the FTP access of a virtual user:</p>
<blockquote><p><code># lftp -u mary -p 60021 192.168.1.101</code></p></blockquote>
<p>The virtual user should have full access to his directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxforfun.net/2008/04/05/vsftpd-virtual-users/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

