<?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>Takahisa's Weblog &#187; sftp</title>
	<atom:link href="http://takahisa.info/tag/sftp/feed/" rel="self" type="application/rss+xml" />
	<link>http://takahisa.info</link>
	<description>weblog of lifetips?</description>
	<lastBuildDate>Fri, 02 Sep 2011 18:27:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>sftp chroot with openssh ERROR : fatal: bad ownership or modes for chroot directory</title>
		<link>http://takahisa.info/2010/03/18/sftp-chroot-with-openssh-error-fatal-bad-ownership-or-modes-for-chroot-directory/</link>
		<comments>http://takahisa.info/2010/03/18/sftp-chroot-with-openssh-error-fatal-bad-ownership-or-modes-for-chroot-directory/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 02:34:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[chroot]]></category>
		<category><![CDATA[sftp]]></category>

		<guid isPermaLink="false">http://takahisa.info/?p=257</guid>
		<description><![CDATA[If you’re playing with the excellent new ChrootDirectory and internal-sftp options in recent OpenSSH releases (such as 5.1 which is in Ubuntu 8.10 Intrepid), you may have hit an error like: fatal: bad ownership or modes for chroot directory You may also have searched on Google for what to do about it and come away [...]]]></description>
			<content:encoded><![CDATA[<p>If you’re playing with the excellent new ChrootDirectory and internal-sftp options in recent OpenSSH releases (such as 5.1 which is in Ubuntu 8.10 Intrepid), you may have hit an error like:</p>
<p>fatal: bad ownership or modes for chroot directory<br />
You may also have searched on Google for what to do about it and come away with very little useful information.</p>
<p>Well no more! I did the same thing and got bored of reading mailing list posts, so read the source code instead. The relevant section is in session.c:</p>
<p>    if (stat(component, &#038;st) != 0)<br />
      fatal(&#8220;%s: stat(\&#8221;%s\&#8221;): %s&#8221;, __func__,<br />
          component, strerror(errno));<br />
    if (st.st_uid != 0 || (st.st_mode &#038; 022) != 0)<br />
      fatal(&#8220;bad ownership or modes for chroot &#8221;<br />
          &#8220;directory %s\&#8221;%s\&#8221;",<br />
          cp == NULL ? &#8220;&#8221; : &#8220;component &#8220;, component);<br />
This is quite simple really, it’s stat()ing the directory specified for “ChrootDirectory” and all its parents up to / and checking that they are:</p>
<p>owned by root<br />
not group or other writable<br />
(it also checks they are actually directories, but I’m going to assume you’re not stupid enough to try and chroot into a file )<br />
Note my emphesis that these checks apply to the chroot directory itself and its parents and /, so if you are chrooting users into /srv/chroot/ then you need to ensure that /, /srv and /srv/chroot are owned by root and not writable by the group (even if it’s root, bizarrely) or other users.</p>
<p>Adopted from : http://www.tenshu.net/archives/2008/10/09/openssh-51-chrootdirectory-permissions-issue/</p>
]]></content:encoded>
			<wfw:commentRss>http://takahisa.info/2010/03/18/sftp-chroot-with-openssh-error-fatal-bad-ownership-or-modes-for-chroot-directory/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

