<?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>Keep [C]*(od&#124;do)ing &#187; macos</title>
	<atom:link href="http://liwen.name/tag/macos/feed/" rel="self" type="application/rss+xml" />
	<link>http://liwen.name</link>
	<description>Grow with the flow</description>
	<lastBuildDate>Fri, 10 Jul 2009 19:37:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Password-less svn+ssh Access on Mac OS X &#8211; Updated</title>
		<link>http://liwen.name/2009/05/passwordless-svnssh-access-on-mac-os-x/</link>
		<comments>http://liwen.name/2009/05/passwordless-svnssh-access-on-mac-os-x/#comments</comments>
		<pubDate>Sun, 03 May 2009 20:57:04 +0000</pubDate>
		<dc:creator>Liwen</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[macos]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://liwen.name/?p=272</guid>
		<description><![CDATA[Related Posts: 1. Install Subversion 1.5.5 on Bluehost Linux 64bit Box 2. Configure svn+ssh on Windows OS After relentless pounding of my fingers on the keyboard just to feed the same password again and again and again to subversion repository in Mac terminal, I realised that typing password is not as fun as developing finger [...]]]></description>
			<content:encoded><![CDATA[<p>Related Posts:</p>
<p>1. <a href="http://liwen.name/2009/02/bluehost-subversion-windows-cmd/">Install Subversion 1.5.5 on Bluehost Linux 64bit Box</a><br />
2. <a href="http://liwen.name/2009/02/configure-svnssh-on-windows/">Configure svn+ssh on Windows OS</a></p>
<p>After relentless pounding of my fingers on the keyboard just to feed the same password again and again and again to subversion repository in Mac terminal, I realised that typing password is not as fun as developing finger habits in my beloved Emacs, although they are both repetitive. </p>
<p>I was reluctant to set up password-less svn+ssh access on my new Mac machine. The reason is that the key pair I am using were both generated by <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" rel="external">Putty</a>, one deployed on Linux server and one for Windows clients. I would rather play Street Fight 4 online for half hour other than reconfigure SSH access across three different operating systems &#8211; if it is not absolutely necessary. They both involve the phrase “pain in the ass”, if you know what I mean :) </p>
<p>Good news is that Mac OS comes with a SSH agent:</p>
<blockquote><p>ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA). The idea is that ssh-agent is started in the beginning of an X-session or a login session, and all other windows or programs are started as clients to the ssh-agent program.  </p></blockquote>
<p>With the ssh agent, we can add the identity once per login. It means &#8216;add once, use everywhere&#8217;! It will be really helpful if you use more than one clients to connect to the same repository server.</p>
<p>Step1:<br />
Use mac os build in <a href="http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/ssh-keygen.1.html#//apple_ref/doc/man/1/ssh-keygen" rel="external">ssh-keygen</a> to generate a pair of openssh format keys. Deploy the public key on your server (assume your server uses openssh) and set up the appropriate permissions (see the related post1 to lean more). If you already have a .ppk key, then a conversion from Putty format to openssh would probably be the easiest way to go. It can be done either using  <a rel="external"  href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuttyGen</a> in Windows OS or using a Putty Mac port (<a href="http://www.macports.org/" rel="external">MacPorts</a> or <a href="http://putty.darwinports.com/" rel="external">DawinPorts</a>). </p>
<p>Step2:<br />
Grant the key file minimum permissions. It needs to be:<br />
<code>chmod u=r,ga-rwx</code> </p>
<p>If you are curious about ssh agent, read step3 and step4, otherwise, just skip to step 5.</p>
<p><del datetime="2009-05-16T10:15:11+00:00">Step3:<br />
Find out the ssh-agent environment variable values: <code>SSH_AUTH_SOCK</code> and <code>SSH_AGENT_PID</code>. For more info about ssh agent in Mac OS, please <a href="http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/ssh-agent.1.html" rel="external">read here</a>.</del></p>
<p><img src="http://liwen.name/images/blog/mac_ssh_agent.jpg" alt="Mac OS SSH agent" /></p>
<p>Step4:<br />
<del datetime="2009-05-04T12:09:26+00:00">Set <code>SSH_AUTH_SOCK</code> and <code>SSH_AGENT_PID</code> environment variables in your subversion client of choice. If you only use command line clients, this step can be skipped.</del><br />
Update: It turned out the <code>SSH_AGENT_PID</code> value changes form login to login. </p>
<blockquote><p><code>/tmp/ssh-XXXXXXXXXX/agent.&lt;ppid&gt;</code><br />
Unix-domain sockets used to contain the connection to the authentication agent.  These sockets should only be readable by the owner.  The sockets should get automatically removed when the agent exits.</p></blockquote>
<p>In this case, the clients need to talk to the OS to find out the value. Since ssh-agent servers as a lower level service in the OS, it seems to be impossible to set up those values for clients manually and I assume it is not necessary.</p>
<p>Setp5:<br />
<del datetime="2009-05-04T12:09:26+00:00">Use ssh-add command to add the key to ssh authentication agent.<br />
<code>ssh-add yourkey</code></del></p>
<p>Find the following three files in the ~/.ssh/ directory (create if not exist).</p>
<blockquote>
<pre>
 ~/.ssh/identity
    Contains the protocol version 1 RSA authentication identity of the user.
 ~/.ssh/id_dsa
    Contains the protocol version 2 DSA authentication identity of the user.
 ~/.ssh/id_rsa
    Contains the protocol version 2 RSA authentication identity of the user.
</pre>
</blockquote>
<p>Append your private key in the right file (depends on the key type) and change the permission to <strong>owner read only</strong>, the ssh-agent will automatically read those files and add identities to the agent every time a ssh request occurs.</p>
<p>Now it&#8217;s really password-less!</p>
<p><img src="http://liwen.name/images/blog/mac_ssh_add.jpg" alt="Mac ssh-add command" /></p>
]]></content:encoded>
			<wfw:commentRss>http://liwen.name/2009/05/passwordless-svnssh-access-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
