<?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>Blog dot Melimato dot Com &#187; bzr central model</title>
	<atom:link href="http://blog.melimato.com/tag/bzr-central-model/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.melimato.com</link>
	<description>Those things we do</description>
	<lastBuildDate>Thu, 24 Dec 2009 11:58:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Configuring a shared repository in Bazaar for users with no shell access</title>
		<link>http://blog.melimato.com/configuring-a-shared-repository-in-bazaar-for-users-with-no-shell-access/</link>
		<comments>http://blog.melimato.com/configuring-a-shared-repository-in-bazaar-for-users-with-no-shell-access/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 13:07:11 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[bzr]]></category>
		<category><![CDATA[bazaar]]></category>
		<category><![CDATA[bzr central model]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[vcs]]></category>

		<guid isPermaLink="false">http://blog.melimato.com/?p=208</guid>
		<description><![CDATA[One of the things that stumbled me the most about bazaar is that it does not have a own authentication method. Users can access repositories through ssh, sftp, etc. While this is very usefull if everyone working on the repo has shell access to the server, it does not allow &#8220;virtual users&#8221; the way svn [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that stumbled me the most about <a href="http://bazaar-vcs.org">bazaar</a> is that it does not have a own authentication method. Users can access repositories through ssh, sftp, etc. While this is very usefull if everyone working on the repo has shell access to the server, it does not allow &#8220;virtual users&#8221; the way svn does. Well, not out of the box anyway&#8230; There&#8217;s always a workaround. This post tries to explain how to configure Bazaar in the <a href="http://doc.bazaar-vcs.org/latest/en/user-guide/central_intro.html">centralized model</a> and set user level permissions to the working directory.</p>
<p><span id="more-208"></span></p>
<h2>Setup initial repository on server</h2>
<p>Init central repository with no working trees, since no-one is going to be committing in the central server. I&#8217;m calling it bzr_test.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #7a0874; font-weight: bold;">cd</span> <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>repo<span style="color: #000000; font-weight: bold;">/</span>base
user<span style="color: #000000; font-weight: bold;">@</span>server$ bzr init-repo <span style="color: #660033;">--no-trees</span> bzr_test</pre></div></div>

<p>Init first branch (trunk) on newly created repo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server$ bzr init bzr_test<span style="color: #000000; font-weight: bold;">/</span>trunk</pre></div></div>

<h2>Securing with bzr_access on server</h2>
<p> (<a href="http://bazaar-vcs.org/BzrAccess">http://bazaar-vcs.org/BzrAccess</a>)</p>
<p>Firstly, get the bzr sources from launchpad, unpack it and copy the bzr_access script located in the contrib directory to some path, I usually use /usr/local/sbin.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>launchpad.net<span style="color: #000000; font-weight: bold;">/</span>bzr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.0</span><span style="color: #000000; font-weight: bold;">/</span>2.0.1<span style="color: #000000; font-weight: bold;">/</span>+download<span style="color: #000000; font-weight: bold;">/</span>bzr-2.0.1.tar.gz
user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxfv bzr-2.0.1.tar.gz
user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #7a0874; font-weight: bold;">cd</span> bzr-2.0.1
user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">cp</span> contrib<span style="color: #000000; font-weight: bold;">/</span>bzr_access <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>bzr_access</pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>bazaar-vcs.org<span style="color: #000000; font-weight: bold;">/</span>bzr<span style="color: #000000; font-weight: bold;">/</span>bzr.dev.knits<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>bzr_access <span style="color: #660033;">-O</span> <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>bzr_access</pre></div></div>

<p>And make sure the script is executable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <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>bzr_access</pre></div></div>

<p>Then, add a system user to be used to access the repository:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> adduser \
    <span style="color: #660033;">--system</span> \
    <span style="color: #660033;">--shell</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> \
    <span style="color: #660033;">--gecos</span> <span style="color: #ff0000;">'bzr version control'</span> \
    <span style="color: #660033;">--group</span> \
    <span style="color: #660033;">--disabled-password</span> \
    <span style="color: #660033;">--home</span> <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>repo \
    bzr_username</pre></div></div>

<p>Once you created the system user, create a .ssh dir in the user&#8217;s home directory (I use the repository&#8217;s root)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~bzr_username<span style="color: #000000; font-weight: bold;">/</span>.ssh
user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">vi</span> ~bzr_username<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>And add the following line (one per user) to the user&#8217;s authorized_keys file:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"># ~bzr_username/.ssh/authorized_keys
<span style="color: #000099;">command</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;/path/to/bzr_access /path/to/bzr /path/to/repo username&quot;</span>,no-port-forwarding,no-X11-forwarding,no-agent-forwarding CLIENT_PUBLIC_KEY</pre></div></div>

<p><em>Parameters</em>:<br />
<strong>/path/to/bzr_access</strong> = /usr/local/sbin/bzr_access<br />
<strong>/path/to/bzr</strong>: Can be found by executing <em>whereis bzr</em>. Usually in /usr/bin/bzr<br />
<strong>/path/to/repo</strong>: /home/development/bzr/bzr_test bzr<br />
<strong>username</strong>: bzr_username<br />
<strong>CLIENT_PUBLIC_KEY</strong>: is the client&#8217;s public key found in ~/.ssh/id_rsa.pub on the client&#8217;s machine</p>
<p>Now, you need to add a bzr_access.conf file to your repo&#8217;s root:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <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>repo<span style="color: #000000; font-weight: bold;">/</span>bzr_access.conf</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"># /path/to/repo/bzr_access.conf
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>groups<span style="">&#93;</span></span>
<span style="color: #000099;">admins</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> admin1</span>
<span style="color: #000099;">devels</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> user1, user2, user3</span>
&nbsp;
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>/<span style="">&#93;</span></span>
@admins <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> rw</span>
@devels <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> r</span></pre></div></div>

<p>OK! Your repo is initted and secured! User admin1 is an admin and cat read &#038; write to the repo while user1, user2 and user3 are devels and have only read access.</p>
<h2>Checkout or branch the repository on the client</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>client$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> bzr_test
user<span style="color: #000000; font-weight: bold;">@</span>client$ <span style="color: #7a0874; font-weight: bold;">cd</span> bzr_test
user<span style="color: #000000; font-weight: bold;">@</span>client$ bzr <span style="color: #c20cb9; font-weight: bold;">co</span> bzr+<span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>bzr_username<span style="color: #000000; font-weight: bold;">@</span>melimato.com<span style="color: #000000; font-weight: bold;">/</span>trunk my_checkedout_trunk
user<span style="color: #000000; font-weight: bold;">@</span>client$ bzr branch bzr+<span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>bzr_username<span style="color: #000000; font-weight: bold;">@</span>melimato.com<span style="color: #000000; font-weight: bold;">/</span>trunk my_branch</pre></div></div>

<h2>Limitations</h2>
<p>Taken from <a href="http://bazaar-vcs.org/BzrAccess">http://bazaar-vcs.org/BzrAccess</a></p>
<blockquote>
<p>Currently, each bzr_access.conf configuration file is limited to specifying the access control for the directory that it is in. As such, to cater for a setup with multiple projects that should be segregated, one must either</p>
<p>Create a user account for each project, thus duplicating the configuration for each user account but allowing each user to maintain just one SSH key pair.</p>
<p>Create a single user account, but require each user to have an SSH key pair for each project. They will then have to select the appropriate private key to access the desired directory. Each of these directories will have its own bzr_access.conf, but there need be only one authorized_keys file.</p>
<p>Create an SSH key pair for each project and have users share private keys. However, removing the access of a user from a given directory will mean revoking a key pair and issuing a new private key to the other users with access to that directory.</p>
</blockquote>
<div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/configuring-a-shared-repository-in-bazaar-for-users-with-no-shell-access/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
