<?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>Zownir Enterprises &#187; ssh</title>
	<atom:link href="http://zownir.net/tag/ssh/feed" rel="self" type="application/rss+xml" />
	<link>http://zownir.net</link>
	<description></description>
	<lastBuildDate>Mon, 10 May 2010 09:02:00 +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>SSH Public Key Authentication</title>
		<link>http://zownir.net/2008/02/26/ssh-public-key-authentication</link>
		<comments>http://zownir.net/2008/02/26/ssh-public-key-authentication#comments</comments>
		<pubDate>Wed, 27 Feb 2008 03:54:00 +0000</pubDate>
		<dc:creator>Ronnie Zownir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MacBook]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[WebFaction]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[If you use ssh a lot, you should really take the time to learn about public key authentication. It is more secure than password based authentication and with the help of ssh-agent, there is no need to enter a passphrase on each and every login. Setup is well worth the effort. I use public key [...]]]></description>
			<content:encoded><![CDATA[<p>If you use ssh a lot, you should really take the time to learn about public key authentication. It is more secure than password based authentication and with the help of ssh-agent, there is no need to enter a passphrase on each and every login. Setup is well worth the effort. I use public key authentication to ssh into my <a href="http://www.webfaction.com?affiliate=rzownir">WebFaction</a> shell account from my Macbook. The following instructions document how I set that up.</p>
<h3>Instructions</h3>
<h4>~/.ssh Directory Creation</h4>
<p>User specific ssh data is stored in the <code>~/.ssh</code> directory. On both the client and the server execute:</p>
<pre><code>mkdir ~/.ssh
chmod 700 ~/.ssh
</code></pre>
<p>If the directory already exists, make sure that the permissions are set to 700 (<code>rwx------</code>).</p>
<h4>Key Pair Generation</h4>
<p>Create the key pair on the client with:</p>
<pre><code>ssh-keygen -q -f ~/.ssh/id_rsa -t rsa
</code></pre>
<p>Enter a passphrase when asked. It should be at least 16 characters long and not your account password.</p>
<h4>Public Half Key Dissemination</h4>
<p>Upload id_rsa.pub to the server with:</p>
<pre><code>scp ~/.ssh/id_rsa.pub username@remote-machine:~/.ssh/
</code></pre>
<p>Replace <code>username</code> and <code>remote-machine</code> accordingly.</p>
<p>The public key data must be appended into the <code>~/.ssh/authorized_keys</code> file on the server:</p>
<pre><code>cat ~/id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
rm ~/.ssh/id_rsa.pub
</code></pre>
<h4>SSH into Remote Machine</h4>
<p>The first time you ssh into the remote machine from the client, execute:</p>
<pre><code>ssh -o PreferredAuthentications=publickey username@remote-machine
</code></pre>
<p>Again, replace <code>username</code> and <code>remote-machine</code> accordingly. You will be asked to enter your passphrase.</p>
<h4>Passphrase Tedium</h4>
<p>Entering the private key passphrase each time you ssh into the remote machine can drive you nuts. If you are using Mac OS X 10.5 (Leopard), you have the option to save the passphrase in the Apple Keychain at the passphrase prompt. This feature isn&#8217;t available in Mac OS X 10.4 (Tiger) and lower. However, <a href="http://www.sshkeychain.org/">SSHKeychain</a> gives you similar functionality. If your using another Unix-like system, check out the first resource below.</p>
<h4>SSHKeychain Primer</h4>
<p>I have a number of iMac G3s that I still use regularly. There is no out of the box keychain integration with Mac OS X 10.4 (Tiger), so I decided I would try out SSHKeychain. Setting up SSHKeychain was a little confusing at first, so I&#8217;ll explain the basics here.</p>
<p>There is nothing special about installation, although an installer is involved rather than a simple drag-and-drop action. Once installed, open up SSHKeychain from the Applications directory. Open up the Preferences dialog box. You can do this three ways. You can click &#8220;SSHKeychain&#8221; at the top left of the menubar and select &#8220;Preferences&#8230;&#8221;, click the keychain icon at the top right of the menubar and select &#8220;Preferences&#8230;&#8221;, or right click/click and hold the icon in the dock and select &#8220;Preferences&#8230;&#8221;. Select the &#8220;Environment&#8221; tab and check the &#8220;Manage (and modify) global environment variables&#8221;. (That&#8217;s what I missed at first.) Select the &#8220;SSH Keys&#8221; tab and remove the default values using the minus sign button (unless those private keys actually do exist).  Select the plus sign button and enter the full path of the private key you just created. For example: <code>/Users/username/.ssh/id_rsa</code>. Close the Preferences dialog box, and click &#8220;Agent&#8221; and select &#8220;Add all keys&#8230;&#8221;. You can find &#8220;Agent&#8221; on the menubar or the dock menu. You will be prompted for the private key passphrase and have the option to add the passphrase to the Apple keychain. I had a problem typing in the entire passphrase in the password field. I solved this by typing it in my favorite text editor and doing a copy and paste. If you have to do this, make sure to copy meaningless text afterward. You really don&#8217;t want your passphrase to be exposed on the clipboard for any significant length of time. Before you ssh into your servers using public key authentication managed by SSHKeychain, restart your computer. It should work nicely afterward. There is much more you can do with SSHKeychain, but the aforementioned should get you going along.</p>
<h4>Disabling Standard Password Authentication</h4>
<p>You may want to make it so that only public key authentication can be used to login to a remote machine using ssh. Check out the second resource for more information.</p>
<h3>Other Resources</h3>
<ul>
<li><a href="http://sial.org/howto/openssh/publickey-auth/">OpenSSH Public Key Authentication</a></li>
<li><a href="http://www.debuntu.org/ssh-key-based-authentication">Secure your SSH server with Public/Private key authentification</a></li>
<li><a href="http://www.dribin.org/dave/blog/archives/2007/11/28/securing_ssh_agent/">Securing ssh-agent on Mac OS X 10.5 (Leopard)</a></li>
<li><a href="http://www.sshkeychain.org/mirrors/SSH-with-Keys-HOWTO/">SSH with Keys HOWTO</a></li>
<li><a href="http://www.extrapepperoni.com/2007/03/24/tcossh-public-key-authentication/">Take Controll of SSH, Draft Excerpt: Public Key Authentication</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zownir.net/2008/02/26/ssh-public-key-authentication/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
