<?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>ArvinderKang.com &#187; public-private keys</title>
	<atom:link href="http://arvinderkang.com/tag/public-private-keys/feed/" rel="self" type="application/rss+xml" />
	<link>http://arvinderkang.com</link>
	<description>The world is my backyard.</description>
	<lastBuildDate>Thu, 29 Jul 2010 22:58:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>In the town called Workflow, lived three friends &#8211; Git, CVS and Drupal&#8230;.</title>
		<link>http://arvinderkang.com/2009/03/02/in-the-town-called-workflow-lived-three-friends-git-cvs-and-drupal/</link>
		<comments>http://arvinderkang.com/2009/03/02/in-the-town-called-workflow-lived-three-friends-git-cvs-and-drupal/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 02:40:58 +0000</pubDate>
		<dc:creator>Arvinder Kang</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[cvs]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[public-private keys]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://arvinderkang.com/2009/03/02/in-the-town-called-workflow-lived-three-friends-git-cvs-and-drupal/</guid>
		<description><![CDATA[Moving ahead on the new project, I decided to install a versioning system. I kinda have a crush on Git, however have not been using it regularly. So what better time to rekindle the old fire? I have used SVN &#8230; <a href="http://arvinderkang.com/2009/03/02/in-the-town-called-workflow-lived-three-friends-git-cvs-and-drupal/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Moving ahead on the new project, I decided to install a <a href="http://en.wikipedia.org/wiki/Revision_control" title="Revision control - Wikipedia, the free encyclopedia">versioning system</a>. I kinda have a crush on Git, however have not been using it regularly. So what better time to rekindle the old fire?</p>

<p>I have used <a href="http://subversion.tigris.org/" title="subversion.tigris.org">SVN</a> in the past, however <a href="http://www.nongnu.org/cvs/" title="CVS - Open Source Version Control">CVS</a> is still the old faithful dog hosting <a href="http://drupal.org/" title="drupal.org | Community plumbing">Drupal</a> repositories. I wanted to concentrate on using <a href="http://git-scm.com/" title="Git - Fast Version Control System">Git</a>, while wanted easy way to update drupal installations.</p>

<p>After a number of blog reads, here is my workflow (atleast planned one&#8230;)</p>

<p><img src="http://arvinderkang.com/wp-content/uploads/2009/03/git-drupal-workflowpng.png" alt="Git Drupal Workflow.png" /></p>

<p><span id="more-182"></span>
Lets start by freeing ourselves from typing in password each time and allowing only public-private key authorization.</p>

<p><strong>Password free remote Login</strong></p>

<p>Following is more or less a shameless rip from <a href="http://www.debuntu.org/ssh-key-based-authentication" title="Secure your SSH server with Public/Private key authentification | Debian/Ubuntu Tips &amp; Tricks">this article</a> (Here for my own reference).</p>

<p>On my local machine, I already had generated ssh key-pair. However in the <code>~/.ssh/</code> folder I found id&#95;dsa, id&#95;dsa.pub pair along with id&#95;rsa, id&#95;rsa.pub pair. Hmmm!  A little digging into the man pages revealed the difference between RSA and DSA.</p>

<pre><code>$ man ssh-keygen
</code></pre>

<p>RSA uses 2048 for encryption by default and can vary, while DSA used exactly 1024.</p>

<p>Lets copy our public key to the server.</p>

<pre><code>$ scp ~/.ssh/id_rsa.pub myusername@myserver:~/
</code></pre>

<p>On my remote server</p>

<pre><code>$ mkdir ~/.ssh
$ cat id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys
$ rm id_rsa.pub
</code></pre>

<p>Lets activate the key</p>

<pre><code>$ sudo su -
# vi /etc/ssh/sshd_config
</code></pre>

<p>Edit the file ensure following options</p>

<pre><code>RSAAuthentication yes
PubkeyAuthentication yes
</code></pre>

<p>Save and quit vim. Relaod the configuration.</p>

<pre><code>$ sudo /etc/init.d/ssh reload
</code></pre>

<p>Now if we access the server from my client machine, it does not asks for a password.</p>

<p>Lets disable authentication by password, to shield brute-force attempts.</p>

<pre><code>$ sudo vi /etc/ssh/sshd_config
</code></pre>

<p>Edit the file ensure following options</p>

<pre><code>....
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
...
</code></pre>

<p>and reload SSH configuration file:</p>

<pre><code>$ sudo /etc/init.d/ssh reload
</code></pre>

<p>Thats it. A machine with a differnt private key would not be able to log in.</p>

<p>I also thought of making my official <a href="http://www.gnupg.org/" title="The GNU Privacy Guard - GnuPG.org">GnuPG/PGP Encryption key</a> and putting it up on the website. But thats for another day.</p>

<p>**Back to our main topic &#8211; Git-svn workflow **</p>

<p>(Inspired by <a href="http://www.versioncontrolblog.com/2007/08/02/upgrading-drupal-52-with-git/" title="Upgrading Drupal with Git | Version Control Blog">Version Control Blog</a>, <a href="http://toolmantim.com/articles/setting_up_a_new_remote_git_repository" title="Setting up a new remote git repository">ToolmanTim</a> and <a href="http://www.aidanf.net/blog/2008/03/28/managing-drupal-installation-cvs-and-git" title="Managing a drupal installation with cvs and git | aidanf.net">Aidanf</a>).</p>

<p>On my local machine</p>

<pre><code>$ mkdir -p ~/src
$ cd src
$ cvs -z9 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -r DRUPAL-6 drupal
$ cd drupal
$ git init
$ git add .
$ git commit -m  "The inital commit of drupal6 core presently at version 6.10"
</code></pre>

<p>Now lets login to server, where we want to host the git repository for redundancy.</p>

<pre><code>$ ssh myusername@myserver
$ mkdir -p ~/gitReps/drupal.git &amp;&amp; cd  ~/gitReps/drupal.git
$ git --bare init
$ exit
</code></pre>

<p>Back on our client machine</p>

<pre><code>$ git remote
</code></pre>

<p>Nothing returns. Good we are on right track.</p>

<pre><code>$ cat .git/config
</code></pre>

<p>Returns</p>

<pre><code>[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
</code></pre>

<p>Lets add remote repository.</p>

<pre><code>git remote add myTux ssh://myusername@myserver/home/myusername/gitReps/drupal.git
</code></pre>

<p>Now above command will return</p>

<pre><code>[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "myTux"]
    url = ssh://myusername@myserver/home/myusername/gitReps/drupal.git
    fetch = refs/heads/*:refs/remotes/myTux/*
</code></pre>

<p>Running <code>git branch</code> shows just one branch locally</p>

<pre><code>* master
</code></pre>

<p>Lets push this to our remote server</p>

<pre><code>$ git push myTux master
Counting objects: 703, done.
Compressing objects: 100% (636/636), done.
Writing objects: 100% (703/703), 1.13 MiB | 1600 KiB/s, done.
Total 703 (delta 29), reused 0 (delta 0)
To ssh://myusername@myserver/home/myusername/gitReps/drupal.git
 * [new branch]      master -&gt; master
</code></pre>

<p>That is our first drupal repository. It would only carry drupal bare-bone code. Any update to drupal-core will be applied here as follows.</p>

<p>Clone the drupal on local machine and update from drupal using cvs. Then update the git and push the changes to remote server.</p>

<pre><code>$ git clone ssh://myusername@myserver/home/myusername/gitReps/drupal.git
$ cd drupal.git
$ cvs update -r DRUPAL-6.11 -dP
$ git status
$ git add .
$ git commit -m "Drupal core updated to version 6.11"
$ git push myTux master
</code></pre>

<p>Now lets create two other seperate clone of this repository. drupal-and-modules.git would keep updates repository along with updated modules and themese. drupal-production.git would keep code ready to be deployed. (I was wondering if some workaround with using branches can solve it? Any suggestions?)</p>

<p>On the server</p>

<pre><code>$ git clone drupal.git drupal-and-modules.git
</code></pre>

<p>On client machine</p>

<pre><code>$ git clone ssh://myusername@myserver/home/myusername/gitReps/drupal-and-modules.git
$ mkdir sites/all/modules
$ cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d sites/all/modules/cck -r DRUPAL-6--2-1 contributions/modules/cck
$ git add .
$ git commit -m "Imported cck 6-2.1 imported"
</code></pre>

<p>Now lets push this changed drupal to drupal-and-modules.git on remote server.</p>

<pre><code>$ git remote
origin
$ git branch
* master
$ git push origin master
Counting objects: 343, done.
Compressing objects: 100% (306/306), done.
Writing objects: 100% (336/336), 375.90 KiB, done.
Total 336 (delta 37), reused 0 (delta 0)
To ssh://myusername@myserver/home/myusername/gitReps/drupal-and-modules.git
   046640c..dc5c0c3  master -&gt; master
</code></pre>

<p>This updates the drupal-and-modules.git.</p>

<p>When drupal.git is updated, drupal-and-modules.git can be updated simply by using command</p>

<pre><code>git pull
</code></pre>

<p>Similarly we can maintain a third repository with all the localization and ready for production.</p>

<p>The implementation worked fine and the workflow should work in theory. However I&#8217;m pretty sure, it will be polished as I use git more and start using rebasing and stashing.</p>
]]></content:encoded>
			<wfw:commentRss>http://arvinderkang.com/2009/03/02/in-the-town-called-workflow-lived-three-friends-git-cvs-and-drupal/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->