<?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>Felipe Alfaro Solana &#187; OpenSSH</title>
	<atom:link href="http://www.felipe-alfaro.org/blog/category/openssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.felipe-alfaro.org/blog</link>
	<description>A little bit of technology, security and networking with Linux, FreeBSD and Mac OS X, plus some personal opinions.</description>
	<lastBuildDate>Sun, 23 Oct 2011 16:46:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>OpenSSH public-keys, ssh-agent and Keychain</title>
		<link>http://www.felipe-alfaro.org/blog/2007/02/03/openssh-public-keys-ssh-agent-and-keychain/</link>
		<comments>http://www.felipe-alfaro.org/blog/2007/02/03/openssh-public-keys-ssh-agent-and-keychain/#comments</comments>
		<pubDate>Sat, 03 Feb 2007 01:27:25 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[OpenSSH]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/2007/02/03/openssh-public-keys-ssh-agent-and-keychain/</guid>
		<description><![CDATA[I have always though that ssh-agent has some limitations. One of those limitations is that when invoked from .bashrc or .zshrc in the following way: `eval ssh-agent` will cause one ssh-agent instance to be spawned for every shell, which is a waste of resources. An easy solution is to use Keychain, which is also described [...]]]></description>
			<content:encoded><![CDATA[<p>I have always though that <code>ssh-agent</code> has some limitations. One of those limitations is that when invoked from <code>.bashrc</code> or <code>.zshrc</code> in the following way:</p>
<div>
<pre>
`eval ssh-agent`
</pre>
</div>
<p>will cause one <code>ssh-agent</code> instance to be spawned for every shell, which is a waste of resources. An easy solution is to use <a href="http://www.gentoo.org/proj/en/keychain/index.xml">Keychain</a>, which is also described <a href="http://www-128.ibm.com/developerworks/linux/library/l-keyc2/">here</a>.</p>
<p>Basically, Keychain is a wrapper for <code>ssh-agent</code>. Keychain will start a <code>ssh-agent</code> and tell it to load one or several private keys. Additionally, Keychain will create two shell scripts into <code>${HOME}/.keychains</code> named <code>${HOST}-sh</code> (for SH-compatible shells) and <code>${HOST}-csh</code> (for CSH-compatible shells) that can be sourced, for example, from within <code>.bashrc</code>, <code>.zshrc</code> or <code>.cshrc</code>, in order to set up the environment variables required for <code>ssh-agent</code> to be usable by other tools like <code>ssh</code>.</p>
<p>A typical <code>${HOME}/.keychains/${HOST}-sh</code> file looks like this:</p>
<div>
<pre>
SSH_AUTH_SOCK=/tmp/ssh-AIVkg1MfHH/agent.942; export SSH_AUTH_SOCK;
SSH_AGENT_PID=943; export SSH_AGENT_PID;
</pre>
</div>
<p>Adding the following lines at the end of <code>.bashrc</code> or <code>.zshrc</code> will get Keychain invoked automatically by the shell:</p>
<div>
<pre>
### KEYCHAIN ###
/opt/local/bin/keychain ~/.ssh/id_dsa
source ~/.keychain/${HOST}-sh
</pre>
</div>
<p>Keychain will search for an existing <code>ssh-agent</code> process. If no existing <code>ssh-agent</code> process exists, Keychain will spawn one telling it to load one or several private keys (passed as parameters to Keychain). Next, Keychain will update <code>${HOME}/.keychain/${HOST}-sh</code> and <code>${HOME}/.keychain/${HOST}-csh</code> to set up the proper environment variables and their corresponding values.</p>
<p>Kudos to Daniel Robbins &#8212; the original author &#8212; and Aron Griffis &#8212; the current Gentoo mantainer. This neat piece of software is extremely useful to me and I use it every day <img src='http://www.felipe-alfaro.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2007/02/03/openssh-public-keys-ssh-agent-and-keychain/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reusing existing OpenSSH v4 connections</title>
		<link>http://www.felipe-alfaro.org/blog/2005/11/11/reusing-existing-openssh-v4-connections/</link>
		<comments>http://www.felipe-alfaro.org/blog/2005/11/11/reusing-existing-openssh-v4-connections/#comments</comments>
		<pubDate>Thu, 10 Nov 2005 22:07:01 +0000</pubDate>
		<dc:creator>Felipe Alfaro Solana</dc:creator>
				<category><![CDATA[OpenSSH]]></category>

		<guid isPermaLink="false">http://felipe-alfaro.org/blog/?p=66</guid>
		<description><![CDATA[Reusing existing OpenSSH v4 connections comments a very interesting feature of OpenSSH 4: reusing open connections. ControlMaster Enables the sharing of multiple sessions over a single network connection. When set to &#8220;yes&#8221; ssh will listen for connections on a control socket specified using the ControlPath argument. ControlPath Specify the path to the control socket used [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.debian-administration.org/articles/290" title="Reusing existing OpenSSH v4 connections">Reusing existing OpenSSH v4 connections</a> comments a very interesting feature of OpenSSH 4: reusing open connections.</p>
<ul>
<li><b>ControlMaster</b>
<p>Enables the sharing of multiple sessions over a single network connection. When set to &#8220;yes&#8221; ssh will listen for connections on a control socket specified using the ControlPath argument.</li>
<li><b>ControlPath</b>
<p>Specify the path to the control socket used for connection sharing as described in the ControlMaster section above or the string &#8220;none&#8221; to disable connection sharing. In the path, &#8216;%h&#8217; will be substituted by the target host name, &#8216;%p&#8217; the port and &#8216;%r&#8217; by the remote login username. It is recommended that any ControlPath used for opportunistic connection sharing include all three of these escape sequences.</li>
</ul>
<blockquote><p>Assume that you&#8217;re on the host itchy and you wish to connect multiple times to the host scratchy.</p>
<p>Connect the first time with :</p>
<pre>ssh scratchy  -M -S /tmp/%r@%h:%p</pre>
<p>Here we&#8217;ve set two options:</p>
<ul>
<li>
<pre>-M</pre>
<p>This is setting the &#8220;ControlMaster&#8221; option.
</li>
<li>
<pre>-S /tmp/%r@%h:%p</pre>
<p>This is the setting for the ControlPath specifying that we should save the master socket as /tmp/user@hostname:port.
</li>
</ul>
<p>Now that we&#8217;ve setup the master connection we can connect a second time with:</p>
<pre>ssh scratchy -S /tmp/%r@%h:%p</pre>
<p>This time the connection is immediate. There is no option negotiation, etc, taking place. We can verify this by adding a
<pre>-v</pre>
<p> flag:</p>
<pre>skx@itchy:~$ ssh -v  scratchy -S /tmp/%r@%h:%p
OpenSSH_4.2p1 Debian-5, OpenSSL 0.9.8a 11 Oct 2005
debug1: Reading configuration data /home/skx/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *

Linux scratchy.my.flat 2.6.8-1-386 #1 ...

The programs included with the Debian GNU/Linux system are free software;
...
...
snip</pre>
<p>There we see the connection just occurs almost immediately, with none of the usual OpenSSH negotiation taking place.</p>
<p>Rather than messing around upon the command line we can setup these options within the configuration file .ssh/config, simply add a new stanza reading:</p>
<pre>Host *
  ControlPath /tmp/%r@%h:%p</pre>
<p>Now we can connect as normal, so long as we make the first connection to any host with
<pre>-M</pre>
<p> (for &#8220;Master&#8221;) all subsequent connections will be much faster.</p>
<p>Cool, huh?</p>
<p>If you don&#8217;t think you can remember to specify the
<pre>-M</pre>
<p> flag for the first one then you can also force this by setting your options to:</p>
<pre>Host *
  ControlMaster auto
  ControlPath /tmp/%r@%h:%p</pre>
<p>(Using autoask instead of auto will force the connection to prompt you whether you wish to setup a socket)
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.felipe-alfaro.org/blog/2005/11/11/reusing-existing-openssh-v4-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

