<?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 Admin Zone &#187; ftp</title>
	<atom:link href="http://linuxadminzone.com/tag/ftp/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxadminzone.com</link>
	<description>Adding more reasons to celebrate Open Source.</description>
	<lastBuildDate>Wed, 09 May 2012 10:17:54 +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>Fix ftp/vsftpd issues in Ubuntu server</title>
		<link>http://linuxadminzone.com/fix-ftpvsftpd-issues-in-ubuntu-server/</link>
		<comments>http://linuxadminzone.com/fix-ftpvsftpd-issues-in-ubuntu-server/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 16:54:36 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vsftpd]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=416</guid>
		<description><![CDATA[This is a quick post describing some issues that you may face while installing/running vsftpd in Ubuntu host. I will quickly walk through steps, beginning with installation and then configuration for general purpose FTP access. 1. Install and run vsftpd without login shell Most obvious thing while running a ftp server is to run it [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick post describing some issues that you may face while installing/running vsftpd in Ubuntu host. I will quickly walk through steps, beginning with installation and then configuration for general purpose FTP access. </p>
<p><strong>1. Install and run vsftpd without login shell</strong></p>
<p>Most obvious thing while running a ftp server is to run it under non login shell. This is quite easy in Redhat based distro but here in Ubuntu, you need to do something extra also to enable users accessing ftp running under non login shell. </p>
<p>Install vsftpd server and start it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> vsftpd
$ <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>vsftpd start</pre></div></div>

<p>Add user who needs ftp access without shell access:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ useradd <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nologin ftpuser</pre></div></div>

<p>Make sure that /usr/sbin/nologin is listed in /etc/shells file otherwise while trying to access ftp, you may encounter following issue:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ftp</span> ftpuser<span style="color: #000000; font-weight: bold;">@</span>serverip
Connected to serverip.
<span style="color: #000000;">220</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>vsFTPd 2.2.2<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000;">331</span> Please specify the password.
Password: 
<span style="color: #000000;">530</span> Login incorrect.
<span style="color: #c20cb9; font-weight: bold;">ftp</span>: Login failed</pre></div></div>

<p>Do not misinterpret the message here that the password is wrong or something, its actually due to shell. </p>
<p>Add /usr/sbin/nologin into /etc/shells file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>shells
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nologin</pre></div></div>

<p>Now try to access ftp server again and you should be able to do it smoothly. </p>
<p><strong>2. Allow user to upload/overwrite files using ftp</strong></p>
<p>Next thing to remember is that the default behavior of vsftpd under Ubuntu is to deny write operation. If you try to upload/overwrite files, you may encounter follow error:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Requested action not taken <span style="color: #7a0874; font-weight: bold;">&#40;</span>e.g., <span style="color: #c20cb9; font-weight: bold;">file</span> or directory not found, no access<span style="color: #7a0874; font-weight: bold;">&#41;</span>.</pre></div></div>

<p>You need to specify explicitly that local users should be able to use ftp and upload/overwrite files by updating configuration:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd.conf
<span style="color: #666666; font-style: italic;">## uncomment local_umask option, it should look like below</span>
<span style="color: #007800;">local_umask</span>=022
&nbsp;
<span style="color: #666666; font-style: italic;">## uncomment write_enable option, it should look like below</span>
<span style="color: #007800;">write_enable</span>=YES</pre></div></div>

<p>Save and close the config file and restart vsftpd service to apply changes.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>vsftpd restart
vsftpd start<span style="color: #000000; font-weight: bold;">/</span>running, process <span style="color: #000000;">13340</span></pre></div></div>

<p>You should be able to use ftp service smoothly now.</p>
<p><strong>3. Allow only secure access to ftp or allow only sftp</strong></p>
<p>FTP is inheriently insecure as it transfer data using plain text. To make sure that user can only access ftp service through a secure channel, replace shell in /etc/passwd to /usr/lib/openssh/sftp-server for the user. </p>
<p>let&#8217;s say you want to make sure that the user &#8216;ftpuser&#8217; can only access ftp through secure channel, then update its entry in /etc/passwd file to look like below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">grep</span> ftpuser <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
ftpuser:x:<span style="color: #000000;">1000</span>:<span style="color: #000000;">1000</span>::<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>work:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>openssh<span style="color: #000000; font-weight: bold;">/</span>sftp-server</pre></div></div>

<p>Do you have any good tips/tricks for ftp users? Please share in comments. </p>
<p>Other related and helpful article you may like to read:<br />
* <a href="http://linuxadminzone.com/5-steps-to-secure-your-linux-server/"> 5 Steps to secure your Linux Server </a><br />
* <a href="http://linuxadminzone.com/top-5-best-and-highly-recommended-books-for-linuxunix-system-admins/"> 5 highly recommended books for aspiring Linux Admins </a><br />
* <a href="http://linuxadminzone.com/ftp-error-could-not-write-to-socket-broken-pipe/"> FTP error &#8211; could not write to socket broken pipe </a><br />
* <a href="http://linuxadminzone.com/ftp-error-500-oops-vsf_sysutil_recv_peek-while-connecting-to-vsftpd/"> FTP error &#8211; 500 oops vsf_sysutil_recv_peek while connecting to vsftpd </a><br />
* <a href="http://linuxadminzone.com/install-and-configure-ftp-server-in-amazon-ec2-instance/"> How to install and configure ftp server in Amazon EC2 instance </a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/fix-ftpvsftpd-issues-in-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FTP Error: Could not write to socket: Broken pipe</title>
		<link>http://linuxadminzone.com/ftp-error-could-not-write-to-socket-broken-pipe/</link>
		<comments>http://linuxadminzone.com/ftp-error-could-not-write-to-socket-broken-pipe/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 06:03:57 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[vsftpd]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=25</guid>
		<description><![CDATA[By viewing this error while using your ftp server, you may get the impression of some bug/problem in your ftp server. This is exactly what happened in the early morning when I got call that vsftpd server in one of the Amazon EC2 server stopped working. When trying to transfer a file it&#8217;s showing something [...]]]></description>
			<content:encoded><![CDATA[<p>By viewing this error while using your ftp server, you may get the impression of some bug/problem in your ftp server. This is exactly what happened in the early morning when I got call that vsftpd server in one of the Amazon EC2 server stopped working. When trying to transfer a file it&#8217;s showing something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Error: Could not <span style="color: #c20cb9; font-weight: bold;">write</span> to socket: Broken pipe
Unable to download <span style="color: #c20cb9; font-weight: bold;">file</span> xxxx</pre></div></div>

<p>In first, I checked the config of vsftpd, and restarted it. It&#8217;s working fine. Then got the clue from &#8220;unable to download file&#8221; messages which indicates that ftp server is not able to write/download file. When I checked the space:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>domU-x-x-x-00-x-E2:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-h</span>
Filesystem            Size  Used Avail Use<span style="color: #000000; font-weight: bold;">%</span> Mounted on
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda1             9.9G  9.4G     <span style="color: #000000;">0</span> <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda2             147G  188M  140G   <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>mnt</pre></div></div>

<p>You can see, 100% space full in / partition. Problem disappeared after cleaning up the space. This server was one of few servers, which were not covered by our nagios implementation then, though this incident accelerated the process. <img src='http://linuxadminzone.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>You may also like to read:<br />
* <a href="http://linuxadminzone.com/5-steps-to-secure-your-linux-server/"> 5 steps to secure your Linux Server </a><br />
* <a href="http://linuxadminzone.com/ensuring-secure-access-to-production-linux-servers/"> Ensuring secure access to production Linux Servers </a><br />
* <a href="http://linuxadminzone.com/bash-script-to-backup-essential-log-files-of-linux-server/"> Bash script to backup essential log files in Linux </a><br />
* <a href="http://linuxadminzone.com/quickly-change-your-ssh-port-from-default-22-to-something-higher/"> Quickly change your ssh port from defualt 22 to something higher </a><br />
* <a href="http://linuxadminzone.com/ssh-port-forwarding-from-remote-to-local-machine/"> SSH port forwarding from remote to local machine </a><br />
* <a href="http://linuxadminzone.com/save-root-or-user-history-to-check-later/"> Save root or user history to check later </a><br />
* <a href="http://linuxadminzone.com/install-and-configure-denyhost/"> Install and configure denyhost to prevent brute force attacks </a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/ftp-error-could-not-write-to-socket-broken-pipe/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Install and Configure FTP Server in Amazon EC2 instance</title>
		<link>http://linuxadminzone.com/install-and-configure-ftp-server-in-amazon-ec2-instance/</link>
		<comments>http://linuxadminzone.com/install-and-configure-ftp-server-in-amazon-ec2-instance/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 06:16:08 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[vsftpd]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=18</guid>
		<description><![CDATA[For many users, running FTP Sever in Amazon EC2 instance is headache at the first time. You need to experiment before being able to transfer data. The main problems are Ingress firewall in Amazon environment and NAT traversal. Here I&#8217;m using vsftp (vsfptd) Server, which is one of the most popular and easy to configure. [...]]]></description>
			<content:encoded><![CDATA[<p>For many users, running FTP Sever in Amazon EC2 instance is headache at the first time. You need to experiment before being able to transfer data. The main problems are Ingress firewall in Amazon environment and NAT traversal.</p>
<p>Here I&#8217;m using vsftp (vsfptd) Server, which is one of the most popular and easy to configure. The instance is running from base Fedora 4 AMI but the setup should be identical to other Red Hat based distros.</p>
<p>Install vsftpd FTP server, if not installed earlier:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ yum <span style="color: #c20cb9; font-weight: bold;">install</span> vsftpd</pre></div></div>

<p>Its upto you which FTP method i.e. Active or Passive you want to use. The problem with active mode is that your computer is sending a request out of port 21 when all of a sudden, the server attempts to initiate a request with your computer on port 20.  Since communication on port 21 does not imply communication on port 20, it appears as if some unauthorized host has attempted to initiate a new connection with your computer.  Kind of sounds like a hack right?  Your firewall may think so too (or your NAT router may have no idea to which computer to route the request). Active mode is not used as default method of ftp transfer in many clients these days. </p>
<p>On the other hand, as the Ingress firewall is running in AWS, from the firewall&#8217;s standpoint, to support passive mode FTP the following communication channels need to be opened:</p>
<p>FTP server&#8217;s port 21 from anywhere (Client initiates connection).<br />
FTP server&#8217;s port 21 to ports > 1023 (Server responds to client&#8217;s control port).<br />
FTP server&#8217;s ports > 1023 from anywhere (Client initiates data connection to random port specified by server).<br />
FTP server&#8217;s ports > 1023 to remote ports > 1023 (Server sends ACKs (and data) to client&#8217;s data port).</p>
<p>That second part is the problem: FTP server listens on a random port and hands that back to the client, so the client initiates a connection to a random server port, which you must allow.</p>
<p>Opening up all ports > 1023 isn&#8217;t so good for security. But what you can do is allow the ports through the distributed firewall and then setup your own filtering inside your instance. Instead, you would better open a fixed number of ports (such as 1024 to 1048) and configure your FTP Server to only use that ports.</p>
<p>Check whether required ports are open or not in your EC2 security group. (if you are unaware about security group, it should be &#8216;defaul&#8217; unless you created a new one).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ec2-describe-group</pre></div></div>

<p>This command will print all ports which are currently open. If you dont find port 20,21,1024-1048 then you need to open these ports but if you dont find the command itself i.e.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ec2-describe-group
-bash: ec2-describe-group: <span style="color: #7a0874; font-weight: bold;">command</span> not found</pre></div></div>

<p>You need to install ec2 command line tools. You can find them <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&#038;categoryID=88">here</a>  and the instructions to setup/configure can be found <a href="http://docs.amazonwebservices.com/AWSEC2/2008-02-01/GettingStartedGuide/?ref=get-started">here.</a> </p>
<p>Open the ports now:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ec2-authorize default <span style="color: #660033;">-p</span> <span style="color: #000000;">20</span>-<span style="color: #000000;">21</span>
$ ec2-authorize default <span style="color: #660033;">-p</span> <span style="color: #000000;">1024</span>-<span style="color: #000000;">1048</span></pre></div></div>

<p>Here, &#8216;default&#8217; is the name of security group. You can also open ports for specific IPs. For ease of use, you better install ElasticFox, a firefox extension to manage EC2 stuff. you can find more about it <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=609">here.</a> </p>
<p>At this moment, you can start your FTP server and if you try to connect it, the process will get failed. By checking logs, you should find something like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: <span style="color: #000000;">257</span> <span style="color: #ff0000;">&quot;/&quot;</span> is current directory.
Command: TYPE A
Response: <span style="color: #000000;">200</span> Type <span style="color: #000000; font-weight: bold;">set</span> to A
Command: PASV
Response: <span style="color: #000000;">227</span> Entering Passive Mode <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">216</span>,<span style="color: #000000;">182</span>,<span style="color: #000000;">238</span>,<span style="color: #000000;">73</span>,<span style="color: #000000;">129</span>,<span style="color: #000000;">75</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.
Command: LIST
Error: Transfer channel can<span style="color: #ff0000;">'t be opened. Reason: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Error: Could not retrieve directory listing</span></pre></div></div>

<p>Time to configure vsftpd.conf file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd<span style="color: #000000; font-weight: bold;">/</span>vsftpd.conf
<span style="color: #666666; font-style: italic;">#&lt;em&gt;---Add following lines at the end of file---&lt;/em&gt;</span>
	<span style="color: #007800;">pasv_enable</span>=YES
	<span style="color: #007800;">pasv_min_port</span>=<span style="color: #000000;">1024</span>
	<span style="color: #007800;">pasv_max_port</span>=<span style="color: #000000;">1048</span>
	<span style="color: #007800;">pasv_address</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>Public IP of your instance<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Put public IP of your EC2 instance and then Save the file. Now restart the server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>vsftpd restart</pre></div></div>

<p>One another thing I noticed recently in some instances is that even after configured properly, ftp client is not able to connect. You can find the description and solution of that problem in <a href="http://linuxadminzone.com/ftp-error-500-oops-vsf_sysutil_recv_peek-while-connecting-to-vsftpd/">this post</a> on this blog. </p>
<p>You may also like to read:<br />
* <a href="http://linuxadminzone.com/5-steps-to-secure-your-linux-server/"> 5 steps to secure your Linux Server </a><br />
* <a href="http://linuxadminzone.com/setting-up-mutiple-mysql-database-servers-on-a-single-linux-machine/"> How to setup multiple mysql servers in a single Linux machine. </a><br />
* <a href="http://linuxadminzone.com/how-to-setup-mysql-cluster-in-amazon-ec2/"> Setup Mysql Cluster in Amazon EC2. </a><br />
* <a href="http://linuxadminzone.com/download-install-and-configure-perlbal-to-load-balance-web-server/"> Download, install and configure perlbal loadbalancer.  </a><br />
* <a href="http://linuxadminzone.com/find-out-the-clients-of-your-mysql-server/"> How to find out clients of your Mysql server. </a><br />
* <a href="http://linuxadminzone.com/optimize-and-fix-mysql-server-running-slow-without-any-load/"> Fix and optimize Mysql server running slow without any load. </a><br />
* <a href="http://linuxadminzone.com/script-to-sync-files-between-web-severs-having-plesk/"> Script to sync files between web servers. </a><br />
* <a href="http://linuxadminzone.com/install-and-configure-haproxy-the-software-based-loadbalancer-in-ubuntu/"> Install and configure HAProxy loadbalancer. </a><br />
* <a href="http://linuxadminzone.com/quick-web-based-php-script-to-check-replication-status-of-mysql/"> Quick web based php script to check replication status of multiple MySQL Servers </a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/install-and-configure-ftp-server-in-amazon-ec2-instance/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
	</channel>
</rss>

