<?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>zanshin.net &#187; ssh</title>
	<atom:link href="http://zanshin.net/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://zanshin.net</link>
	<description>because not enough websites start with the letter "Z"</description>
	<lastBuildDate>Fri, 20 Aug 2010 13:25:21 +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>Using SSHFS, MacFUSE, and Macfusion to Access Remote Filesystems</title>
		<link>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F11%2F06%2Fusing-sshfs-macfuse-and-macfusion-to-access-remote-filesystems%2F&amp;seed_title=Using+SSHFS%2C+MacFUSE%2C+and+Macfusion+to+Access+Remote+Filesystems</link>
		<comments>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F11%2F06%2Fusing-sshfs-macfuse-and-macfusion-to-access-remote-filesystems%2F&amp;seed_title=Using+SSHFS%2C+MacFUSE%2C+and+Macfusion+to+Access+Remote+Filesystems#comments</comments>
		<pubDate>Fri, 06 Nov 2009 15:29:47 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[nerdliness]]></category>
		<category><![CDATA[macfuse]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sshfs]]></category>

		<guid isPermaLink="false">http://zanshin.net/?p=2160</guid>
		<description><![CDATA[SSHFS sshfs is a secure file system client that allows you to access and manipulate files on remote systems where that would normally be available via SFTP. sshfs is dependent upon FUSE or Filesystem in Userspace. FUSE is available for Linux, FreeBSD, NetBSD (as PUFFS), OpenSolaris, and Mac OS X (as MacFUSE). It was officially [...]]]></description>
			<content:encoded><![CDATA[<h2>SSHFS</h2>
<p>sshfs is a secure file system client that allows you to access and manipulate files on remote systems where that would normally be available via SFTP. sshfs is dependent upon FUSE or Filesystem in Userspace. FUSE is available for Linux, FreeBSD, NetBSD (as PUFFS), OpenSolaris, and Mac OS X (as MacFUSE). It was officially merged into the mainstream Linux kernel tree in kernel version 2.6.14.  h1.</p>
<h2>The Pieces of the Puzzle</h2>
<p>You will need to install three applications / frameworks:</p>
<ol>
<li><a title="MacFUSE" href="http://code.google.com/p/macfuse" target="_blank">MacFuse</a></li>
<li><a title="Macfusion" href="http://www.macfusionapp.org" target="_blank">Macfusion</a></li>
<li><a title="sshfs" href="http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS" target="_blank">sshfs</a> (to update the pre-installed version that comes with Macfusion)</li>
</ol>
<h2>Installing MacFuse</h2>
<p>MacFuse is an OS X implementation of the <a title="Filesystem in Userspace (Wikipedia)" href="http://en.wikipedia.org/wiki/Filesystem_in_Userspace" target="_blank">Filesystem in Userspace</a> (FUSE) framework. FUSE provides an API to write a virtual file system. Variations of the virtual file system include:</p>
<ul>
<li>PicasawebFS, for manipulation images in a Picasa account like they were stored on your local machine</li>
<li>RSSFS, which allows you to mount an RSS feed as a filesystem and access each entry as an individual file</li>
<li>SSHFS, or the Secure Shell Filesystem, which allows you to mount a remote computer directory through a secure shell (SSH) login.</li>
</ul>
<p><strong>Download and install MacFuse from Google Code:</strong> <a title="MacFUSE" href="http://code.google.com/p/macfuse" target="_blank">http://code.google.com/p/macfuse</a></p>
<p>At present the preference pane that MacFuse installs is 32-bit, so your System Preferences will restart in 32-bit mode when you select the MacFuse pane. The only option it exposes is a check for updates.</p>
<h2>Installing Macfusion</h2>
<p>Macfusion is an open source SSHFS mounting application for Mac OS X.</p>
<p><strong>Download and install from:</strong> <a title="Macfusion" href="http://www.macfusionapp.org" target="_blank">http://www.macfusionapp.org </a></p>
<h3>Setting up an SSHFS file system</h3>
<p>Once Macfusion is installed, start the application and click on the plus icon in the bottom left of the main window and choose SSHFS.</p>
<p><img class="aligncenter size-full wp-image-2161" title="Macfusion_sshfs" src="http://zanshin.net/wp-content/uploads/2009/11/Macfusion_sshfs.png" alt="Macfusion_sshfs" width="513" height="202" /></p>
<h3>Set SSHFS mount parameters</h3>
<p>Under the <strong>SSH</strong> tab:</p>
<ul>
<li><strong>Host:</strong> The _hostname_ of the server that you SSH to.</li>
<li><strong>User name:</strong> Your SSH username.</li>
<li><strong>Password:</strong> Your SSH password. (At present I don&#8217;t know how to enable this via SSH Keys.)</li>
<li><strong>Path:</strong> This can be left blank.</li>
</ul>
<p><img class="aligncenter size-full wp-image-2162" title="Macfusion_ssh_tab" src="http://zanshin.net/wp-content/uploads/2009/11/Macfusion_ssh_tab.png" alt="Macfusion_ssh_tab" width="499" height="321" /></p>
<p>Under the <strong>SSH Advanced</strong> tab:</p>
<ul>
<li><strong>Port:</strong> The default SSH port is 22 unless the server uses a different one.</li>
<li><strong>Follow Symbolic Links:</strong> Leave this checked</li>
</ul>
<p><img class="aligncenter size-full wp-image-2163" title="Macfusion_ssh_advanced_tab" src="http://zanshin.net/wp-content/uploads/2009/11/Macfusion_ssh_advanced_tab.png" alt="Macfusion_ssh_advanced_tab" width="494" height="326" /></p>
<p>Under the <strong>Macfusion</strong> tab:</p>
<ul>
<li><strong>Mount Point and Volume Name:</strong> Can be left blank.</li>
<li><strong>Ignore Apple Double Files:</strong> You must uncheck this if you plan to <em>open/edit/save</em> files on the mounted volume. While allowing for remote editing of files is a powerful feature there is a downside. Mac OS X will place .DS_Store and ._* (Apple double) files on the server. OS X utilizes these hidden files for enhanced filesystem features and extended attributes in non-OS X filesystems. Since they start with a dot (.) these files should be invisible on the remote system. You may leave this option checked if you only plan to <em>copy/move/delete</em> files (it will also increase speed).</li>
<li><strong>Enable Negative VNode Cache:</strong> This is an optimization to increase speed and should generally be left checked, <strong>unless</strong> files can appear on the mounted volume from the server side of the connection. For example, if multiple users are using your mounted disk space leave this unchecked.</li>
</ul>
<p><img class="aligncenter size-full wp-image-2164" title="Macfusion_macfusion_tab" src="http://zanshin.net/wp-content/uploads/2009/11/Macfusion_macfusion_tab.png" alt="Macfusion_macfusion_tab" width="494" height="391" /></p>
<h2>Mounting the Remote filesystem</h2>
<p>You are now ready to mount the SSHFS on your desktop. Click on the mount button and if the SSH settings are correct you should have a green disk icon mounted on the desktop. (Note, you may need to visit the Finder preferences to make sure that you are allowing *Connected Servers* to be displayed.)  You should now be able to access the remote files as if they were on an external disk attached to your system. You can copy, move, rename, and delete files. Remember, that in order to edit files you must <strong>uncheck </strong>the <em>Ignore Apple Double Files</em> option. This can only be done with the remote filesystem is unmounted.</p>
<h3>sshnodelay.so Error</h3>
<p>If the mount operation fails, click the gear icon in the Macfusion main window and select the Log option (or use Cmd-L with Macfusion as the active application). If you see the following error message:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dyld: could not load inserted library: <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>Macfusion.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>Plugins<span style="color: #000000; font-weight: bold;">/</span>sshfs.mfplugin<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>Resources<span style="color: #000000; font-weight: bold;">/</span>sshnodelay.so</pre></div></div>

<p style="text-align: center;"><img class="aligncenter size-full wp-image-2165" title="Macfusion_log_viewer" src="http://zanshin.net/wp-content/uploads/2009/11/Macfusion_log_viewer.png" alt="Macfusion_log_viewer" width="452" height="274" /></p>
<p>Then you need to rename or remove that library. Navigate to the <strong>/Applications/Macfusion.app/Contents/Plugins/sshfs.mfplugin/Contents/Resources</strong> directory and rename (e.g., sshnodelay.orig) or remove the sshnodelay.so file.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-2166" title="Macfusion_rename_sshnodelay" src="http://zanshin.net/wp-content/uploads/2009/11/Macfusion_rename_sshnodelay.png" alt="Macfusion_rename_sshnodelay" width="577" height="136" /></p>
<h2>Update SSHFS</h2>
<p>Now that you have a working connection it is time to verify the version of sshfs included with Macfusion, and update it if necessary.   Using the Terminal, navigate to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>Macfusion<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>Plugins<span style="color: #000000; font-weight: bold;">/</span>sshfs.mfplugin<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>Resources</pre></div></div>

<p>The copy of sshfs that Macfusion uses is located in this directory. Run the command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> $ .<span style="color: #000000; font-weight: bold;">/</span>sshfs-static <span style="color: #660033;">-V</span></pre></div></div>

<p>to verify the installed version. As of this writing the current available version of sshfs was 2.2, if the displayed version is anything less than that, you will see a performance increase by updating.</p>
<p><strong>Download SSHFS from: </strong><a title="sshfs download" href="http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS" target="_blank">http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS </a></p>
<p>For Mac OS X 10.6 you want to get the <strong>sshfs-static-leopard.gz</strong> file. Uncompress the gzip archive. Inside the resulting sshfs-binaries folder will be an application called <em>sshfs-static-leopard</em>.  In Terminal rename the original sshfs-static application (assuming you are still in the /Applications/Macfusion/Contents/Plugins/sshfs.mfplugin/Contents/Resources directory):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mv</span> sshfs-static sshfs-static-orig</pre></div></div>

<p>And then copy the new version into place:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mv</span> ~<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>sshfs-binaries<span style="color: #000000; font-weight: bold;">/</span>sshfs-static-leopard sshfs-static</pre></div></div>

<p>This should result in a significant performance increase.</p>
<h2>Preventing .DS_Store files over Network Connections</h2>
<p>You can prevent .DS_Store files from being created on the mounted filesystem by executing the following command in Terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ defaults <span style="color: #c20cb9; font-weight: bold;">write</span> com.apple.desktopservices DSDontWriteNetworkStores <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p>This will affect interactions with SMB/CIFS, AFP, NFS, and WebDav servers.  You will need to restart the computer or log out and back in to your user account for this change to take effect.</p>
]]></content:encoded>
			<wfw:commentRss>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F11%2F06%2Fusing-sshfs-macfuse-and-macfusion-to-access-remote-filesystems%2F&amp;seed_title=Using+SSHFS%2C+MacFUSE%2C+and+Macfusion+to+Access+Remote+Filesystems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managing ssh keys</title>
		<link>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F10%2F09%2Fmanaging-ssh-keys%2F&amp;seed_title=Managing+ssh+keys</link>
		<comments>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F10%2F09%2Fmanaging-ssh-keys%2F&amp;seed_title=Managing+ssh+keys#comments</comments>
		<pubDate>Sat, 10 Oct 2009 01:53:56 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[nerdliness]]></category>
		<category><![CDATA[public key]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://zanshin.net/?p=2008</guid>
		<description><![CDATA[Earlier this evening, while not paying close enough attention to what I was doing, I managed to delete some semi-important files on my desktop at work. The error happened because I was remotely logged in via the command line and wasn&#8217;t paying attention to which machine I was actually working against. My error is recoverable [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this evening, while not paying close enough attention to what I was doing, I managed to delete some semi-important files on my desktop at work. The error happened because I was remotely logged in via the command line and wasn&#8217;t paying attention to which machine I was actually working against. My error is recoverable but it gives me new respect for the working environment system administrators live in day in and day out.</p>
<p>The files I deleted where the public and private key pair that uniquely identify my work desktop, and the list of public keys my work desktop has added to its authorized keys list. No real harm done except that now when I try to remotely login to that computer I have to enter the password. I decided to start over and document the process so I can perform it again in the future, if need be.</p>
<h2>Step One</h2>
<p>Generate a key pair on each machine you regularly use. In my case I have two work computers, a desktop called Palantir and a laptop called Orthanc, and two personal computers, both laptops, called Eeyore and Tigger. On Unix based systems run the ssh-keygen command to create a new public and private key pair. Like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa
Generating public<span style="color: #000000; font-weight: bold;">/</span>private rsa key pair.
Enter <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #c20cb9; font-weight: bold;">which</span> to save the key <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>mhn<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa<span style="color: #7a0874; font-weight: bold;">&#41;</span>:
Enter passphrase <span style="color: #7a0874; font-weight: bold;">&#40;</span>empty <span style="color: #000000; font-weight: bold;">for</span> no passphrase<span style="color: #7a0874; font-weight: bold;">&#41;</span>:
Enter same passphrase again:
Your identification has been saved <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>mhn<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.
Your public key has been saved <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>mhn<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub.</pre></div></div>

<p>The id_rsa file is my identification and private key. The id_rsa.pub file is my public key. In order to make copying the public key to other machines easier I made a copy of the id_rsa.pub file on each machine, using the machine&#8217;s name as a unique identifier.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cp</span> id_rsa.pub machineName.pub</pre></div></div>

<h2>Step Two</h2>
<p>Next I copied the public keys from each machine into a folder in my Dropbox:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cp</span> .pub ~<span style="color: #000000; font-weight: bold;">/</span>Dropbox<span style="color: #000000; font-weight: bold;">/</span>public_keys<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Since I can access my Dropbox from all of my machines, and since the key files are named for the machine they represent, this is a elegant way to house them centrally. You could also use scp (secure copy) to accomplish the same thing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">scp</span> machineName.pub you<span style="color: #000000; font-weight: bold;">@</span>othermahince.com:~<span style="color: #000000; font-weight: bold;">/</span>.ssh</pre></div></div>

<h2>Step Three</h2>
<p>Once you have the key files on the remote machine or in  your Dropbox, ssh (secure shell) into that machine and change to the .ssh directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> you<span style="color: #000000; font-weight: bold;">@</span>remoteMachine.com
Password:
$ <span style="color: #7a0874; font-weight: bold;">cd</span> .ssh</pre></div></div>

<p>Make sure the authorized_keys file exists in the .ssh directory using the touch command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">touch</span> authorized_keys</pre></div></div>

<p>Concatenate the public key from the other machine to the authorized_keys file,</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cat</span> machineName.pub <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> authorized_keys</pre></div></div>

<p>Repeat the concatenation for each machine you want access this computer from remotely.</p>
<h2>Step Four</h2>
<p>There is no step four. You&#8217;re done.</p>
<h2>Step Five</h2>
<p>I also used the named public key files to allow password-less access to my bitbucket account.</p>
<p><strong>NB:</strong> These steps worked for me. You should probably read more about <a title="Quick Logins with ssh Client Keys" href="http://oreilly.com/pub/h/66">ssh keys</a>, <a title="Copying Files with scp" href="http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/04eaff076bce249dca256fb6007f53e5?OpenDocument">scp</a>, and <a title="Secure Shell" href="http://en.wikipedia.org/wiki/Secure_Shell">ssh</a> before attempting to follow them. Especially if you&#8217;ve never done this before.</p>
]]></content:encoded>
			<wfw:commentRss>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F10%2F09%2Fmanaging-ssh-keys%2F&amp;seed_title=Managing+ssh+keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharing iTunes Beyond Your Subnet</title>
		<link>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F02%2F05%2Fsharing-itunes-beyond-your-subnet%2F&amp;seed_title=Sharing+iTunes+Beyond+Your+Subnet</link>
		<comments>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F02%2F05%2Fsharing-itunes-beyond-your-subnet%2F&amp;seed_title=Sharing+iTunes+Beyond+Your+Subnet#comments</comments>
		<pubDate>Thu, 05 Feb 2009 20:09:08 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[nerdliness]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://zanshin.net/?p=1788</guid>
		<description><![CDATA[iTunes allows you to share your music library with other computers based on the same subnet of your network. Network addressing is too arcane a subject for this posting, but a simplified explanation will help. Each computer on a network gets a unique address, know as an IP address. (IP stands for Internet Protocol.) IP [...]]]></description>
			<content:encoded><![CDATA[<p>iTunes allows you to share your music library with other computers based on the same subnet of your network. Network addressing is too arcane a subject for this posting, but a simplified explanation will help. Each computer on a network gets a unique address, know as an IP address. (IP stands for Internet Protocol.) IP addresses have four sets of numbers, separated by a dot, e.g., 192.168.101.10. For licensing reasons Apple restricts the sharing of music to computers that have identical addresses except for the last portion of the IP address. If your computer has an address of 198.162.101.1, then any computer with an address of 192.168.101.* can receive your shared music.</p>
<p>Currently I have a situation where I&#8217;d like to share my music to a computer that isn&#8217;t on the same subnet. It turns out this is possible, if a bit cumbersome. I&#8217;m basing my instructions below on the much more detailed instructions I found the <a title="SSH Tunnel MtdWiki" href="http://wiki.mt-daapd.org/wiki/SSH_Tunnel" target="_blank">SSH Tunnel MtdWiki</a>.  </p>
<p>Make sure you can establish a secure shell (ssh) connection from the client (listening) computer and the server (playing) computer. Open Terminal and type</p>
<pre>ssh userid@192.168.1.1</pre>
<p>where userid is the user account you have on the computer you&#8217;ll be using as the server. And where 192.168.1.1 is the IP address that machine has.</p>
<p>If this works then you are ready for the next step. If it doesn&#8217;t work, you&#8217;ll need to visit the Sharing preference pane (for Mac OS X 10.4.x) and make sure that Remote Login is enabled. While you are there, make sure that iTunes Music Sharing is also enabled.</p>
<p>Step two is to create a secure shell tunnel between the listening computer and the playing computer. One of the more useful features of ssh tunnels is the ability to forward a port from one computer to another. Services that listen to or respond at specific ports can be forwarded through a ssh tunnel to remote machines. iTunes uses port 3689 for sharing music. We want to establish a tunnel between our two computers that ties port 3689 on the listening computer to port 3689 on the playing computer. Something like this:</p>
<pre>ssh userid@192.168.1.1 -N -f -L 3689:192.168.1.1:3689</pre>
<p>Here&#8217;s a breakdown of the command:</p>
<p><span style="font-family: 'Courier New'; line-height: 18px; white-space: pre;"><strong>s</strong></span><strong>sh userid@192.168.1.1</strong> is the normal secure shell login command. The <strong>-N</strong> flag makes it a non-interactive session, and the <strong>-f</strong> flag causes the whole command to run in the background, both of which free up your command line for other activities. The <strong>-L</strong> flag establishes the port forwarding from port 3689 on the listening machine to the same port on the playing machine.</p>
<p>Next you will need to install a <a title="Network Beacon" href="http://www.chaoticsoftware.com/ProductPages/NetworkBeacon.html" target="_blank">Network Beacon</a>, which allows iTunes to see the DAAP port (3689). The one I used is freely available from <a title="Chaotic Software" href="http://www.chaoticsoftware.com/" target="_blank">Chaotic Software</a>. Since iTunes is geared to only &#8220;see&#8221; shared music from the same subnet, you need something to act as a proxy for the remote server. In this case Network Beacon acts as that proxy, allowing the copy on the listening machine to see the music on the playing machine through the secure tunnel and port forward we created above.</p>
<p>Here&#8217;s an image of how to configure the beacon on the listening machine:</p>
<p><img class="alignnone" src="http://zanshin.net/images/beacon.png" alt="" width="451" height="377" /></p>
<p> </p>
<p>With the beacon enabled, and the tunnel established, start iTunes on your listening computer and wait a few moments while the shared library is populated under the &#8220;Shared&#8221; heading in the sidebar.</p>
]]></content:encoded>
			<wfw:commentRss>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2009%2F02%2F05%2Fsharing-itunes-beyond-your-subnet%2F&amp;seed_title=Sharing+iTunes+Beyond+Your+Subnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically Update Your Uptime In WordPress</title>
		<link>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2008%2F08%2F22%2Fautomatically-update-your-uptime-in-wordpress%2F&amp;seed_title=Automatically+Update+Your+Uptime+In+WordPress</link>
		<comments>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2008%2F08%2F22%2Fautomatically-update-your-uptime-in-wordpress%2F&amp;seed_title=Automatically+Update+Your+Uptime+In+WordPress#comments</comments>
		<pubDate>Fri, 22 Aug 2008 15:36:55 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[nerdliness]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://zanshin.net/?p=1563</guid>
		<description><![CDATA[Recently I read an article on how to capture, upload, and display your computer&#8217;s uptime in the footer of your blog. Automatically update your computer&#8217;s uptime on your website does a very good job of laying out the basic techniques for accomplishing this, admittedly nerdy, task.  However, the original script uses FTP, or File Transfer [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I read an article on how to capture, upload, and display your computer&#8217;s uptime in the footer of your blog. <a title="Automatically update your computer's uptime on your website" href="http://www.wesg.ca/2008/06/automatically-update-your-computers-uptime-on-your-website/">Automatically update your computer&#8217;s uptime on your website</a> does a very good job of laying out the basic techniques for accomplishing this, admittedly nerdy, task.  However, the original script uses FTP, or File Transfer Protocol, to move the formatted uptime information from your computer to your web site host. Using Secure Copy, or scp, would be a better solution.</p>
<h2>SCP</h2>
<p>Secure copy, or scp, encrypts data being transfered so that man-in-the-middle attacks aren&#8217;t possible.  I&#8217;ll show you the original script, and then  my script which employs scp instead of ftp.  I&#8217;m also using a private-public key pair for authentication, so that there is no need for my host password to be either transmitted or stored in the script.</p>
<h2>The Original Script</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">#mark as executable</span>
<span style="color: #666666; font-style: italic;"># get the uptime data</span>
<span style="color: #007800;">days</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">uptime</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/,//g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">hours</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">uptime</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $5}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/,//g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">label</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">uptime</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
 
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$days</span>&quot;</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">day_label</span>=<span style="color: #ff0000;">'day'</span>
<span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #007800;">day_label</span>=<span style="color: #ff0000;">'days'</span>
<span style="color: #000000; font-weight: bold;">fi</span>
 
<span style="color: #666666; font-style: italic;">#format labels</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$hours</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">hour_label</span>=<span style="color: #ff0000;">'hour'</span>
<span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #007800;">hour_label</span>=<span style="color: #ff0000;">'hours'</span>
<span style="color: #000000; font-weight: bold;">fi</span>
 
<span style="color: #666666; font-style: italic;">#format output</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$label</span>&quot;</span> = <span style="color: #ff0000;">'mins,'</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'My MacBook has been on for '</span><span style="color: #007800;">$days</span> minutes<span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; uptime.txt
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$label</span>&quot;</span> = <span style="color: #ff0000;">'day,'</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$label</span>&quot;</span> = <span style="color: #ff0000;">'days,'</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'My MacBook has been on for '</span><span style="color: #007800;">$days</span> <span style="color: #007800;">$day_label</span>, <span style="color: #007800;">$hours</span> <span style="color: #007800;">$hour_label</span><span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; uptime.txt
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$label</span>&quot;</span> = <span style="color: #ff0000;">'2'</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'My MacBook has been on for '</span><span style="color: #007800;">$days</span> hours<span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; uptime.txt
<span style="color: #000000; font-weight: bold;">fi</span>
 
<span style="color: #666666; font-style: italic;">#upload to the website</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">hostname</span></span>=<span style="color: #ff0000;">&quot;FTP address&quot;</span>
<span style="color: #007800;">username</span>=<span style="color: #ff0000;">&quot;FTP username&quot;</span>
<span style="color: #007800;">password</span>=<span style="color: #ff0000;">&quot;FTP password&quot;</span>
 
<span style="color: #c20cb9; font-weight: bold;">ftp</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$hostname</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt;EOF
 
quote USER <span style="color: #007800;">$username</span>
quote PASS <span style="color: #007800;">$password</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>wordpress<span style="color: #000000; font-weight: bold;">/</span>uploads
put uptime.txt
EOF
 
<span style="color: #666666; font-style: italic;">#move the uptime file back to its original place</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> uptime.txt <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">file</span>
 
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;task completed&quot;</span></pre></div></div>

<p>As you can see, in the &#8220;upload to the website&#8221; section of the script, the host user id and password are stored.  While this works, it is probably not the best approach.  By generating a ssh key pair, we can eliminate the need for the user id and password, and we can clean up the code using scp.</p>
<h2>ssh-keygen</h2>
<p>Run this command in Terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa</pre></div></div>

<p>This program creates a pair of encryption keys, public and private, using the RSA encryption scheme. It will prompt you for a filename where it will save the private key. (The public key will be created with the same filename, but with an additional <code>.pub</code> extension.) By default, it will want to save the key as<code>~/.ssh/id_rsa</code>, which, being one of the default filenames for keys that scp (and ssh) recognizes, will be perfect for our purposes.  Hit return to enter a blank pass phrase, and then return again to confirm a blank pass phrase. (Using ssh-agent would allow using a pass phrase protected key, but that is beyond the scope of this posting.)</p>
<p>Next you want to log onto the remote machine, your web host, and create (if it doesn&#8217;t already exist) a .ssh directory.  Note the leading dot, which makes this directory hidden to the normal <strong><em>ls</em></strong> command.  To see if you already have one, type</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-a</span></pre></div></div>

<p>at the command prompt on your web host. </p>
<p>Once you&#8217;ve created the .ssh directory you are ready to copy the public half of the key pair to your host.  The public key on your local machine will (by default) be called id_rsa.pub.  We are going to rename it as we copy it to the remote machine to authorized_keys2.  (If you already have an authorized_keys2 file on the remote machine, you will need to concatenate the new key to the exiting ones.)</p>
<p>We&#8217;ll use the scp command to copy, and rename, the public key:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">scp</span> id_rsa.pub yourid<span style="color: #000000; font-weight: bold;">@</span>remotehost.com:~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys2</pre></div></div>

<p>You will have to provide the correct values for <strong><em>yourid</em></strong> and the <strong><em>remotehost.com</em></strong> name.  Since we haven&#8217;t yet copied the key to the remote machine you will be asked for your password.  In the future, however, having the keys setup will let this command, and others like it, run without requiring a password.</p>
<p>With our keys in place we can now modify the uptime script to use scp.  </p>
<h2>The Modified Script</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># timeup.sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get the uptime data</span>
<span style="color: #007800;">days</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">uptime</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3} '</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/,//g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">hours</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">uptime</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $5} '</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/,//g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">label</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">uptime</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $4} '</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$days</span>&quot;</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #007800;">day_label</span>=<span style="color: #ff0000;">'day'</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #007800;">day_label</span>=<span style="color: #ff0000;">'days'</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># format labels</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$hours</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #007800;">hour_label</span>=<span style="color: #ff0000;">'hour'</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #007800;">hour_label</span>=<span style="color: #ff0000;">'hours'</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># format output</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$label</span>&quot;</span> = <span style="color: #ff0000;">'mins,'</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'My Powerbook has been on for '</span><span style="color: #007800;">$days</span> minutes<span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; uptime.text
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$label</span>&quot;</span> = <span style="color: #ff0000;">'day,'</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$label</span>&quot;</span> = <span style="color: #ff0000;">'days,'</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'My Powerbook has been on for '</span><span style="color: #007800;">$days</span> <span style="color: #007800;">$day_label</span>, <span style="color: #007800;">$hours</span> <span style="color: #007800;">$hour_label</span><span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; uptime.text
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$label</span>&quot;</span> = <span style="color: #ff0000;">'2'</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'My Powerbook has been on for '</span><span style="color: #007800;">$days</span> hours<span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; uptime.text
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># upload to web host</span>
<span style="color: #666666; font-style: italic;"># relies upon ssh-key for authentication</span>
<span style="color: #c20cb9; font-weight: bold;">scp</span> uptime.text <span style="color: #c20cb9; font-weight: bold;">id</span><span style="color: #000000; font-weight: bold;">@</span>remotehost:<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>wordpress<span style="color: #000000; font-weight: bold;">/</span>uploads<span style="color: #000000; font-weight: bold;">/</span>uptime.textontent<span style="color: #000000; font-weight: bold;">/</span>uploads<span style="color: #000000; font-weight: bold;">/</span>uptime.text
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;task completed&quot;</span></pre></div></div>

<p>Now you can follow the rest of the steps at the <a title="Automatically update your computer's uptime on your website" href="http://www.wesg.ca/2008/06/automatically-update-your-computers-uptime-on-your-website/">Automatically update your computer&#8217;s uptime on your website</a> article, and know that your information is being copied without exposing your id, password, or the file contents thanks to scp and ssh-keygen.</p>
]]></content:encoded>
			<wfw:commentRss>http://zanshin.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fzanshin.net%2F2008%2F08%2F22%2Fautomatically-update-your-uptime-in-wordpress%2F&amp;seed_title=Automatically+Update+Your+Uptime+In+WordPress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
