<?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>-= n8v =- &#187; Cygwin</title>
	<atom:link href="http://n8v.enteuxis.org/tags/cygwin/feed/" rel="self" type="application/rss+xml" />
	<link>http://n8v.enteuxis.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 27 Sep 2011 00:52:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2-beta2-18055</generator>
		<item>
		<title>PHPUnit for XAMPP on Windows with Cygwin</title>
		<link>http://n8v.enteuxis.org/2011/09/phpunit-for-xampp-on-windows-with-cygwin/</link>
		<comments>http://n8v.enteuxis.org/2011/09/phpunit-for-xampp-on-windows-with-cygwin/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 23:30:41 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Figuring IT Out]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=510</guid>
		<description><![CDATA[Steps to get PHPUnit to run on my XAMPP setup with Cygwin, so I can write and run Symfony2 unit tests. 1. Upgrade PEAR Download http://pear.php.net/go-pear.phar to C:\xampp\php\go-pear.phar Run this in cmd.exe (cygwin prompts hosed somehow), taking all defaults c:\xampp\php&#62;go-pear.bat Yay. c:\xampp\php&#62;pear version PEAR Version: 1.9.4 PHP Version: 5.3.5 Zend Engine Version: 2.3.0 Running on: [...]]]></description>
			<content:encoded><![CDATA[<p>Steps to get PHPUnit to run on my XAMPP setup with Cygwin, so I can write and run Symfony2 unit tests.</p>

<h3>1. Upgrade PEAR</h3>

<ol>
<li><p>Download <code>http://pear.php.net/go-pear.phar</code>  to <var>C:\xampp\php\go-pear.phar</var></p></li>
<li><p>Run this <strong>in <var>cmd.exe</var></strong> (cygwin prompts hosed somehow), taking all defaults</p></li>
</ol>


<div class="wp_syntax"><div class="code"><pre class="dos">c:\xampp\php<span class="sy0">&gt;</span>go-pear.bat</pre></div></div>


<ol>
<li>Yay.</li>
</ol>


<div class="wp_syntax"><div class="code"><pre class="dos">c:\xampp\php<span class="sy0">&gt;</span>pear version
PEAR Version: 1.9.4
PHP Version: 5.3.5
Zend Engine Version: 2.3.0
Running on: Windows NT FAI1046162 6.1 build 7600 <span class="sy0">(</span>Unknow Windows version Enterpr
ise Edition<span class="sy0">)</span> i586</pre></div></div>


<h3>2. Install/upgrade PHPUnit</h3>

<p>Now we can use the cygwin shell.  Not sure <a href="http://forum.kohanaframework.org/discussion/7346/installing-phpunit-on-windows-xampp/p1">all these channels are needed</a>, I did this out of order.</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw3">cd</span> <span class="sy0">/</span>cygdrive<span class="sy0">/</span>c<span class="sy0">/</span>xampp<span class="sy0">/</span>php
pear update-channels
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear channel-discover pear.phpunit.de
&nbsp;
pear <span class="kw2">install</span> <span class="re5">--alldeps</span> phpunit<span class="sy0">/</span>PHPUnit</pre></div></div>


<h3>3. Use it</h3>

<p>XAMPP and/or PHPUnit come with a wrapper called <var>phpunit.bat</var>, which has now been upgraded, but you may need to set your <var>PHPBIN</var> environment var. Also I already have <var>c:\xampp\php</var> in my <var>$PATH</var>.</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw3">export</span> <span class="re2">PHPBIN</span>=c:<span class="sy0">/</span>xampp<span class="sy0">/</span>php<span class="sy0">/</span>php.exe
&nbsp;
<span class="kw3">cd</span> <span class="sy0">/</span>path<span class="sy0">/</span>to<span class="sy0">/</span>mysf2project
phpunit.bat <span class="re5">-c</span> app</pre></div></div>


<p>Now PHPUnit works. Make tests and make them work!</p>
]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2011/09/phpunit-for-xampp-on-windows-with-cygwin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Open files in Emacs from the Cygwin command line</title>
		<link>http://n8v.enteuxis.org/2011/05/open-files-in-emacs-from-the-cygwin-command-line/</link>
		<comments>http://n8v.enteuxis.org/2011/05/open-files-in-emacs-from-the-cygwin-command-line/#comments</comments>
		<pubDate>Fri, 27 May 2011 23:43:09 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Figuring IT Out]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=430</guid>
		<description><![CDATA[I just got this working today. The weirdnesses of Cygwin&#8217;s half Unix-half Windows nature had stymied me before, but I&#8217;ve prevailed! I&#8217;ve got Gnu Emacs 23.3 for Windows installed in c:/emacs, and a fairly recent install of Cygwin on Windows 7. Saved this script in ~/cygemacs.sh #!/usr/bin/bash c:/emacs/bin/emacsclientw.exe -n -a &#34;c:/emacs/bin/runemacs.exe&#34; `cygpath -wa $@` Then [...]]]></description>
			<content:encoded><![CDATA[<p>I just got this working today. The weirdnesses of Cygwin&#8217;s half Unix-half Windows nature had stymied me before, but I&#8217;ve prevailed!</p>

<p>I&#8217;ve got <a href="http://ftp.gnu.org/gnu/emacs/windows/">Gnu Emacs 23.3 for Windows</a> installed in <var>c:/emacs</var>, and a fairly recent install of <a href="http://cygwin.com/">Cygwin</a> on Windows 7.</p>

<p>Saved this script in <var>~/cygemacs.sh</var></p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="co0">#!/usr/bin/bash</span>
c:<span class="sy0">/</span>emacs<span class="sy0">/</span>bin<span class="sy0">/</span>emacsclientw.exe <span class="re5">-n</span> <span class="re5">-a</span> <span class="st0">&quot;c:/emacs/bin/runemacs.exe&quot;</span> <span class="sy0">`</span>cygpath <span class="re5">-wa</span> $<span class="sy0">@`</span></pre></div></div>


<p>Then in my <var>~/.bashrc</var>:</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw3">alias</span> <span class="re2">ec</span>=<span class="st0">&quot;~/cygemacs.sh&quot;</span></pre></div></div>


<p>Now I can be all like,</p>


<div class="wp_syntax"><div class="code"><pre class="bash">$ ec ~<span class="sy0">/</span>.minttyrc</pre></div></div>


<p>And it opens a new frame in my running Emacs (I have <code>(server-start)</code> in my <var>~/.emacs</var>), or starts Emacs and opens the file if Emacs isn&#8217;t running yet.</p>

<p>See also: <a href="http://www.emacswiki.org/emacs/EmacsClient">EmasClient at EmacsWiki</a>.</p>

<h3>Bonus tips</h3>

<p>Yes I&#8217;m still using Subversion but also gitting going with Git.</p>

<p>And courtesy of <a href="http://shreevatsa.wordpress.com/2007/01/06/using-emacsclient/">The Lumber Room</a>, <var>in ~/.bashrc</var> and others:</p>


<div class="wp_syntax"><div class="code"><pre class="bash">    <span class="kw3">export</span> <span class="re2">SVN_EDITOR</span>=<span class="st_h">'c:/emacs/bin/emacsclientw.exe -a c:/emacs/bin/runemacs.exe '</span></pre></div></div>


<p>And silence that annoying &#8220;kill client buffer z0mgbbq?!?&#8221; warning:</p>


<div class="wp_syntax"><div class="code"><pre class="lisp">  <span class="br0">&#40;</span>remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-<span class="kw1">function</span><span class="br0">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2011/05/open-files-in-emacs-from-the-cygwin-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Secure AND More Convenient: Secure Shell keys and agents everywhere you go</title>
		<link>http://n8v.enteuxis.org/2009/05/more-secure-and-more-convenient-secure-shell-keys-and-agents-everywhere-you-go/</link>
		<comments>http://n8v.enteuxis.org/2009/05/more-secure-and-more-convenient-secure-shell-keys-and-agents-everywhere-you-go/#comments</comments>
		<pubDate>Fri, 29 May 2009 00:50:50 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Figuring IT Out]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[public key]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=38</guid>
		<description><![CDATA[As security increases, convenience tends to decrease. But in this case we gain some of both. CONCEPTS Problem 1: Brute force SSH attackers I recently made a Linux machine accessible by port 22 from the Internet, so I could remotely administer it with SSH. Within a day or two, there were hosts from all over [...]]]></description>
			<content:encoded><![CDATA[<p>As security increases, convenience tends to decrease.  But in this case we gain some of both.</p>

<h2>CONCEPTS</h2>

<h3>Problem 1: Brute force SSH attackers</h3>

<p>I recently made a Linux machine accessible by port 22 from the Internet, so I could remotely administer it with SSH.  Within a day or two, there were hosts from all over the Internet trying to log in using random usernames (&#8216;root&#8217;, &#8216;dave&#8217;, &#8216;mysql&#8217;, &#8216;neo&#8217;) and random passwords.</p>

<h3>Problem 2: Weak system passwords</h3>

<p>System passwords are becoming easier to guess by brute force every time a new processor comes out.  It doesn&#8217;t matter how complicated your alphabet soup is, it&#8217;s just not long enough, or won&#8217;t be long enough eventually.  The bad guys also have botnets full of machines and all the time in the world.</p>

<h3>Working around problems 1 and 2: Key authentication</h3>

<p>An SSH key is complex (random) and much, much longer than your password (<a href="http://en.wikipedia.org/wiki/Public-key_cryptography">see Wikipedia for more details about how public-key cryptography works</a>).  You store the private part of your key securely on your client machine, and tell the server to trust only the public key that goes with it.  BUT, you should really use a nice, long, complex passphrase to lock up your private key so that someone who gains access to it can&#8217;t get free access to all your servers, which leads to</p>

<h3>Problem 3:  I&#8217;m too lazy to unlock my inconvenient SSH key all the time</h3>

<p>I log in to different machines all the time, from a bunch of different workstations.  But, I have a long passphrase on my SSH key.  Too long to type every time, especially if I&#8217;m just looking at something or transferring a file or two.</p>

<h3>Solution to problem 3:  A key agent</h3>

<p>An SSH key agent lets you unlock your key and load it into memory once, and then automatically uses it to get you in to all your servers.  SUPER convenient.</p>

<h3>Problem 4:  It&#8217;s confusing</h3>

<p>I tried to explain it to a friend recently and found nowhere on the internets that explained it all in one place.</p>

<p>Coming up:  detailed instructions for getting started with SSH keys and using a key agent on Mac OS X (command line), Windows (PuTTY and Cygwin commandline ssh), and Linux/Unix (command line).</p>

<p><span id="more-38"></span></p>

<h2>HOW TO START USING SSH KEYS</h2>

<h3>References:</h3>

<ul>
<li><a href="http://www.tartarus.org/~simon/puttydoc/Chapter8.html#pubkey">PuTTY manual chapter 8</a>
and <a href="http://www.tartarus.org/~simon/puttydoc/Chapter9.html">chapter 9</a></li>
<li>section 2.4 of the <a href="http://www.snailbook.com/">O&#8217;Reilly SSH book by Barrett/Silverman</a></li>
<li><code>man <a href="http://linux.die.net/man/5/ssh_config">ssh_config</a></code></li>
<li><code>man <a href="http://linux.die.net/man/1/ssh-agent">ssh-agent</a></code></li>
</ul>

<h3>Generate your key with a command-line (Open)SSH client (Cygwin, Mac OS X, Linux)</h3>

<p>I&#8217;m going to start with this client, because the command-line OpenSSH is the common denominator on all the OSes I use.</p>

<ol>
<li><p>Write down a nice long, complex, memorable passphrase that you&#8217;re capable of typing reliably, and store it in a safe place.  You probably won&#8217;t need it every day (unless you reboot a lot), so make sure you can remember and type it.  Security expert Bruce Schneier suggests <a href="http://www.schneier.com/blog/archives/2005/06/write_down_your.html">a scrap of paper in your wallet is a pretty good place</a>.</p></li>
<li><p>Generate a private key with <var>ssh-keygen </var>from your client machine&#8217;s command line:</p></li>
</ol>


<div class="wp_syntax"><div class="code"><pre class="bash">$ <span class="kw2">ssh-keygen</span> <span class="re5">-t</span> rsa
Generating public<span class="sy0">/</span>private rsa key pair.
Enter <span class="kw2">file</span> <span class="kw1">in</span> <span class="kw2">which</span> to save the key <span class="br0">&#40;</span><span class="sy0">/</span>home<span class="sy0">/</span>myusername<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa<span class="br0">&#41;</span>:
Enter passphrase <span class="br0">&#40;</span>empty <span class="kw1">for</span> no passphrase<span class="br0">&#41;</span>:     <span class="co0"># use yours from step 1</span>
Enter same passphrase again:
Your identification has been saved <span class="kw1">in</span> <span class="sy0">/</span>home<span class="sy0">/</span>myusername<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa.
Your public key has been saved <span class="kw1">in</span> <span class="sy0">/</span>home<span class="sy0">/</span>myusername<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa.pub.
The key fingerprint is:
9a:<span class="nu0">89</span>:9c:6b:<span class="nu0">87</span>:a7:e8:<span class="nu0">93</span>:9a:f5:f7:<span class="nu0">35</span>:bf:<span class="nu0">23</span>:<span class="nu0">87</span>:c6 myusername<span class="sy0">@</span>myhostname</pre></div></div>


<ol>
<li>The file permissions of your new <var>.ssh</var> directory and the files in it (except maybe your public key) should be very restrictive, allowing only you to read them.  But just in case, reset them restrictively:</li>
</ol>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">chmod</span> <span class="nu0">700</span> ~<span class="sy0">/</span>.ssh
<span class="kw2">chmod</span> <span class="nu0">600</span> ~<span class="sy0">/</span>.ssh<span class="sy0">/*</span>
<span class="kw2">chmod</span> <span class="nu0">644</span> ~<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa.pub</pre></div></div>


<ol>
<li>You need to append your public key to <var>~/.ssh/authorized_keys</var> on each of your servers:

<ul>
<li>if you don&#8217;t have an authorized_keys file in your <var>~/.ssh</var> directory, just copy your public key to it on each server:</li>
</ul></li>
</ol>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">scp</span> <span class="re5">-r</span> ~<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa.pub  myserver:.ssh<span class="sy0">/</span>authorized_keys</pre></div></div>


<ul>
<li>if you already have one, you&#8217;ll need to append your key to it.  Use a text editor and paste, copy and paste, or, courtesy of <a href="http://codesnippets.joyent.com/posts/show/906">CodeSnippets</a>,</li>
</ul>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw2">cat</span> .ssh<span class="sy0">/</span>id_dsa.pub <span class="sy0">|</span> <span class="kw2">ssh</span> user<span class="sy0">@</span>domain.tld <span class="st_h">'cat &gt;&gt; .ssh/authorized_keys'</span></pre></div></div>


<ol>
<li>Test and make sure it works!  When you ssh to the server, it should prompt you for your passphrase to unlock your private key, and then you should successfully connect.  Using the -d flag to ssh gives you verbose debugging information which is usually useful.</li>
</ol>


<div class="wp_syntax"><div class="code"><pre class="bash">$ <span class="kw2">ssh</span> <span class="re5">-v</span> myserver
... <span class="co0"># copious debug information about which keys or </span>
... <span class="co0"># authentication methods ssh is trying ]</span>
Enter passphrase <span class="kw1">for</span> key <span class="st_h">'~/.ssh/id_rsa'</span>:
... <span class="co0"># here's where you type your passphrase correctly</span>
... <span class="co0"># more debugging</span>
debug1: Entering interactive session.
Last <span class="kw2">login</span>: Thu May <span class="nu0">21</span> <span class="nu0">14</span>:<span class="nu0">30</span>:<span class="nu0">31</span> <span class="nu0">2009</span> from 10.0.0.2</pre></div></div>


<ol>
<li><p>I like to turn on agent forwarding by adding this line to <var>~/.ssh/config</var> file on each server.  This allows you to ssh from server A to another server B that trusts your key, using the agent on your client machine to pass your key through.
ForwardAgent yes</p></li>
<li><p>If all the users on the server will be using keys from now on, it&#8217;s a good idea to turn off password authentication for the whole server, in sshd_config, which is usually located in <var>/etc/</var>:
PasswordAuthentication no
Unfortunately, I can&#8217;t figure out how to lock one account on the server from using password authentication.  You can put that line in your <var>~/.ssh/config</var> file, but it only affects your use of ssh <em>from</em> that account, not <em>to</em> it.</p></li>
</ol>

<h3>Or, generate your key with PuTTY on Windows:</h3>

<p>PuTTY is rock-solid terminal and SSH software for Windows.  I usually generate my key with the command-line OpenSSH tools and then import it to PuTTY, but here&#8217;s how you do it the other way around:</p>

<ol>
<li><p>Install the <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">latest version of the whole PuTTY package</a>.  At the time of this writing, the PuTTY author&#8217;s site has been inaccessible for a while, but there are <a href="http://the.earth.li/~sgtatham/putty/0.60/x86/">mirrors available</a> for downloading the software.</p></li>
<li><p>Generate an RSA key with puttygen.exe, using a good passphrase (see instructions in the <a href="http://www.tartarus.org/~simon/puttydoc/Chapter8.html#pubkey">PuTTY manual chapter 8</a>)
<div id="attachment_233" class="wp-caption alignnone" style="width: 493px"><img src="http://n8v.enteuxis.org/wp-content/uploads/2009/05/puttygen.png" alt="Generating a key with puttygen.exe" title="puttygen" width="483" height="471" class="size-full wp-image-233" /><p class="wp-caption-text">Generating a key with puttygen.exe</p></div></p></li>
<li><p>Save the private key somewhere using the &#8216;Save private key&#8217; button, like maybe in <var>C:\Documents and Settings\<samp>yourusername</samp>&#92;.ssh\puttyprivkey</var> to be compatible with command-line SSH tools.  Save the public key somewhere too (though you will paste it, below).</p></li>
<li><p>Make the file permissions of that directory and the files in it very restrictive (only you should have access).</p></li>
<li><p>On one server, edit <var>.ssh/authorized_keys</var> in your home directory (creating it if it doesn&#8217;t exist yet), and paste your public key from puttygen in there</p></li>
<li><p>Test that it works!  Tell PuTTY to try key authentication instead of password authentication by setting your private key under Connection->SSH->Auth in the connection settings:
<div id="attachment_232" class="wp-caption alignnone" style="width: 466px"><img src="http://n8v.enteuxis.org/wp-content/uploads/2009/05/putty_ssh_key_settings.png" alt="Tell PuTTY to use your key" title="putty_ssh_key_settings" width="456" height="442" class="size-full wp-image-232" /><p class="wp-caption-text">Tell PuTTY to use your key</p></div></p></li>
<li><p>Copy the <var>authorized_keys</var> file and/or the whole <var>.ssh</var> directory to each other server.  Eg on the first server, <code>scp -r .ssh myotherserver:</code></p></li>
<li><p>Turn on agent forwarding (and &#8220;try to use Pageant&#8221;&#8230; see screenshot above) for each ssh session config in PuTTY in the Connection-&gt;SSH-&gt;Auth pane (this lets you ssh from server A to another server using the agent on your client machine)</p></li>
<li><p>Put your username in the &#8220;Auto-login username&#8221; field under Connection-&gt;Data for each saved PuTTY session:
<div id="attachment_249" class="wp-caption alignnone" style="width: 466px"><img src="http://n8v.enteuxis.org/wp-content/uploads/2009/05/putty_username.png" alt="Don&#039;t forget to fill in the Auto-login username field for each saved PuTTY session." title="putty_username" width="456" height="442" class="size-full wp-image-249" /><p class="wp-caption-text">Don't forget to fill in the Auto-login username field for each saved PuTTY session.</p></div></p></li>
</ol>

<h4>Using your PuTTY key with command-line ssh client (Cygwin, Mac OS X, Linux):</h4>

<p>If you want to use the key you just generated with puttygen.exe with
another ssh client (eg cygwin commandline <var>ssh</var>), export your
private key from puttygen and store it in your <var>.ssh</var> dir
(ssh looks by default for <var>.ssh/id_rsa</var> but these
instructions let you specify another name), and put these lines in
your <var>.ssh/config</var> file:</p>

<pre><code>ForwardAgent yes
IdentityFile ~/.ssh/id_rsa_putty_priv.openssh
</code></pre>

<p>( i.e., the filename of your exported private key )</p>

<h4>To change your ssh key password</h4>

<p>Load it in <var>puttygen</var> and change the password, save and
export it for your other ssh client(s) if necessary</p>

<h4>Using a different key from home or another machine or whatever</h4>

<p>You can copy your private key to several machines, or you can generate
a new key on each and append the public key to the
<var>.ssh/authorized_keys</var> file on the server. Think about how
much you want to expose/replace if something gets compromised.</p>

<p>In my case, I use one private key on all my client computers at work, one
on my home computers, and one on my Palm handheld. That way if one of
my client computers is lost, stolen or compromised, I can disallow
that key but keep the others.</p>

<h2>USE A KEY AGENT TO KEEP YOUR KEYS HANDY</h2>

<p>So far, we&#8217;ve made SSH more secure, but my key passphrase is at least as much of a pain as using my password &#8212; in fact, more so because it&#8217;s about twice as long.</p>

<p>Using an SSH Key Agent offers a killer mix of security <em>and</em> convenience.  When you open the agent and load your keys, you can unlock them and they&#8217;re held unlocked in memory.  This lets you open connections all day without having to type your password or passphrase.  <strong>NOTE WELL</strong>, lock your machine when it is unattended if you have an agent running; otherwise anyone who walks up to it can conceivably log in to any of the servers you&#8217;ve configured to trust your key.</p>

<h3>To use PuTTY&#8217;s agent &#8220;Pageant&#8221; on Windows:</h3>

<ol>
<li>Launch <var>pageant.exe</var>, PuTTY&#8217;s ssh agent, right-click it in the system tray, and add your private key.</li>
</ol>

<p>Now you can log into all your servers conveniently and get from server to server using agent forwarding.</p>

<p>You may want to convince pageant.exe to run at login.  See <a href="http://www.tartarus.org/~simon/puttydoc/Chapter9.html">Chapter 9 of the PuTTY manual</a>.</p>

<p>I just made a shortcut to pageant and edited the Target to load the key and launch PuTTY at startup thusly:
<code>
"C:\Program Files\putty\pageant.exe" "C:\Documents and Settings\myusername&#46;ssh\puttyprivkey.ppk" -c "C:\Program Files\PuTTY\putty.exe"</code></p>

<h3>To run an agent with the command-line OpenSSH client:</h3>

<p>This applies to Linux, Mac OS X, and Cygwin.</p>

<p>Basically, add this line to your <var>.profile</var> file in your home directory, to start the agent whenever you open a shell:</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw3">eval</span> <span class="sy0">`</span><span class="kw2">ssh-agent</span> -s<span class="sy0">`</span></pre></div></div>


<p>Then, before you ssh to anything in that terminal, use the <code>ssh-add</code> command (if your private key in openssh format is named <var>.ssh/id_rsa</var>) or <code>ssh-add ~/.ssh/puttyprivkey.openssh</code> if you&#8217;ve got a weirdly named one you made with puttygen.exe, above.</p>


<div class="wp_syntax"><div class="code"><pre class="bash">$ <span class="kw2">ssh-add</span>
Enter passphrase <span class="kw1">for</span> <span class="sy0">/</span>cygdrive<span class="sy0">/</span>c<span class="sy0">/</span>Documents and Settings<span class="sy0">/</span>myusername<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa:
Identity added: <span class="sy0">/</span>cygdrive<span class="sy0">/</span>c<span class="sy0">/</span>Documents and Settings<span class="sy0">/</span>myusername<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa <span class="br0">&#40;</span><span class="sy0">/</span>cygdrive<span class="sy0">/</span>c<span class="sy0">/</span>Documents and Settings<span class="sy0">/</span>myusername<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa<span class="br0">&#41;</span></pre></div></div>


<p><code>ssh-add -l</code> (ell) shows which keys the agent is currently holding.</p>


<div class="wp_syntax"><div class="code"><pre class="bash">$ <span class="kw2">ssh-add</span> <span class="re5">-l</span>
9a:<span class="nu0">89</span>:9c:6b:<span class="nu0">87</span>:a7:e8:<span class="nu0">93</span>:9a:f5:f7:<span class="nu0">35</span>:bf:<span class="nu0">23</span>:<span class="nu0">87</span>:c6 <span class="sy0">/</span>cygdrive<span class="sy0">/</span>c<span class="sy0">/</span>Documents and Settings<span class="sy0">/</span>myusername<span class="sy0">/</span>.ssh<span class="sy0">/</span>id_rsa <span class="br0">&#40;</span>RSA<span class="br0">&#41;</span></pre></div></div>


<h3>Making it nicer in with <code>keychain</code></h3>

<p>The <a href="http://www.gentoo.org/proj/en/keychain/">keychain
utility</a> you can get with Cygwin (and some Linuxes) is also nice.
I put this line in my <var>.bashrc</var> so that every Cygwin shell
either starts the ssh agent or connects to the already running one.</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw3">eval</span> <span class="sy0">`</span>keychain <span class="re5">--eval</span> <span class="re5">-q</span> <span class="re5">-Q</span> --noask<span class="sy0">`</span></pre></div></div>


<p>Then I can use <var>ssh-add</var> (see above) when I want to load my keyring, and
all my open Cygwin shells get it, until I log out or restart Windows.</p>

<h3>Running an agent on Mac OS X</h3>

<p>In Leopard (Mac OS X 10.5, released in October 2007), the <a href="http://www.dribin.org/dave/blog/archives/2007/11/28/ssh_agent_leopard/">SSH Agent is integrated into the OS</a>, so if you&#8217;ve generated your keys with <code>ssh-keygen</code> as above and they live in <code>~/.ssh/id_rsa</code> and <code>id_rsa.pub</code>, you will get prompted to unlock your key the first time you try to <code>ssh</code> or <code>scp</code> anywhere:</p>

<div id="attachment_253" class="wp-caption alignnone" style="width: 591px"><img src="http://n8v.enteuxis.org/wp-content/uploads/2009/05/leopard-ssh-agent.png" alt="This dialog box prompts you to unlock your key and/or start the agent." title="leopard-ssh-agent" width="581" height="414" class="size-full wp-image-253" /><p class="wp-caption-text">This dialog box prompts you to unlock your key and/or start the agent.</p></div>

<p>The &#8220;Remember password in my keychain&#8221; checkbox makes it keep an ssh agent running.  It works great.</p>

<p>For older versions of Mac OS, you want <a href="http://www.sshkeychain.org/download.php">SSHKeychain</a>.  It also works with the Apple Keychain, to remember your key&#8217;s passphrase.</p>

<p>Both solutions work seamlessly for all the OpenSSH tools (ssh, sftp, scp, etc) in all your terminals.</p>
]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2009/05/more-secure-and-more-convenient-secure-shell-keys-and-agents-everywhere-you-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

