<?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>Wise on Tech &#187; SSH</title>
	<atom:link href="http://www.wiseontech.com/tag/ssh/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wiseontech.com</link>
	<description>Hacks, scripts and ideas for the refined geek.</description>
	<lastBuildDate>Thu, 22 Jul 2010 14:48:15 +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 AppleScript and a Shell Script to Restart an AppleTV remotely</title>
		<link>http://www.wiseontech.com/hack/using-applescript-and-a-shell-script-to-restart-an-appletv-remotely</link>
		<comments>http://www.wiseontech.com/hack/using-applescript-and-a-shell-script-to-restart-an-appletv-remotely#comments</comments>
		<pubDate>Mon, 21 Jul 2008 23:43:46 +0000</pubDate>
		<dc:creator>Jonathan Wise</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[AppleTV]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://software.jonandnic.com/?p=110</guid>
		<description><![CDATA[Both my media serving devices (a NAS, and a Mac Mini) are using TwonkyVision Media Server to share media using uPnP. It works great, but as I mentioned earlier, I needed a script to make it start back up in the morning. Unfortunately, I've found that my AppleTV freaks out a bit when this happens, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright alignnone size-full wp-image-111" style="float: right;" title="appletv" src="http://www.wiseontech.com/wp-content/uploads/2008/07/appletv.jpg" alt="" width="225" height="125" /></p>
<p>Both my media serving devices (a NAS, and a Mac Mini) are using TwonkyVision Media Server to share media using uPnP. It works great, but as I <a href="http://www.wiseontech.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy53aXNlb250ZWNoLmNvbS9oYWNrL3Jlc3RhcnQtdHdvbmt5bWVkaWEtYWZ0ZXItc2NoZWR1bGVkLXNsZWVw">mentioned earlier</a>, I needed a script to make it start back up in the morning.</p>
<p>Unfortunately, I've found that my AppleTV freaks out a bit when this happens, and as a result, needs its own reboot. Restarting the Finder helps, but streaming still gets weird, so a full, daily reboot is in order. Using the same iCal-alarm-firing-an-AppleScript trick, I updated my Twonky restart script to also tell the AppleTV to restart. But it wasn't that easy.</p>
<ul>
<li>First of all, you need to <a href="http://www.wiseontech.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy53aXNlb250ZWNoLmNvbS9oYWNrL2dlbmVyYXRpbmctcnNhLWtleXBhaXJzLW9uLW1hYy1vcy14LWZvci1hLW5peC13ZWItc2VydmVy">exchange keypairs</a> with the AppleTV so that you can login over ssh without a password. If you're using an older patchstick, the process is a little different, since it may only support ssh1. This wiki page explains the process, and the <a href="http://www.wiseontech.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3dpa2kuYXdrd2FyZHR2Lm9yZy93aWtpL2luZGV4LnBocD90aXRsZT1JbnN0YWxsX1NTSCNVc2luZ19Qcm90b2NvbF8x">slight tweak to it for ssh1</a>.</li>
</ul>
<ul>
<li>Second, you need to set the AppleTV up to allow you to sudo without a password. This is harder than it sounds, and requires modifying the /etc/sudoers file on the AppleTV. The only way I found to do that was to <code>sudo cat /etc/sudoers &gt; ~/sudoers</code> the file (which <a href="http://www.wiseontech.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5yZWRoYXQuY29tL2RvY3MvbWFudWFscy9saW51eC9SSEwtOS1NYW51YWwvZ2V0dGluZy1zdGFydGVkLWd1aWRlL3MxLW5hdmlnYXRpbmctdXNpbmdjYXQuaHRtbA==">dumps the contents of one file to another</a>, which you can access more easily), copy it over to my Mac, edit it, copy it back, set the permissions, and sudo mv it back over-top the original. You'll need to add this line to the bottom of the sudoers file:<code><br />
frontrow ALL=(ALL) NOPASSWD: ALL<br />
</code></li>
<li><strong>Make sure you change the permissions (chmod 0440) and ownership (chown root:wheel) on your new sudoers</strong> <strong><em>before </em>you replace the original, or you'll screw yourself out of sudo!</strong></li>
</ul>
<p>To test those things, you could go to Terminal on your Mac and try something like:<br />
<code>ssh -1 frontrow@appletv.local 'sudo ls-l'</code></p>
<p><em>(drop the -1 for newer Patchsticks)</em></p>
<p>If you've setup everything right, you shouldn't get prompted for a password to login OR to get a directory listing. Once that works, the AppleScript is easy and looks like this:</p>
<p><code>do shell script "ssh -1 frontrow@appletv.local 'sudo reboot' &amp;&gt; /dev/null &amp;"</code></p>
<p><em>(drop the -1 for newer Patchsticks)</em></p>
<p>At some point, I'm also going to attach this to a PHP script (somehow) so I can use Safari on my iPhone to do a reboot from the couch if needed. I've only found two other ways to reboot the AppleTV -- yanking the power cord, or using the remote to put it in recovery mode. Neither seems as elegant as my solution.</p>
 <img src="http://www.wiseontech.com/wp-content/plugins/feed-statistics.php?view=1&post_id=110" width="1" height="1" style="display: none;" /><img src="http://www.wiseontech.com/?ak_action=api_record_view&id=110&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.wiseontech.com/hack/using-applescript-and-a-shell-script-to-restart-an-appletv-remotely/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Generating RSA Keypairs on Mac OS X for a *nix web-server</title>
		<link>http://www.wiseontech.com/hack/generating-rsa-keypairs-on-mac-os-x-for-a-nix-web-server</link>
		<comments>http://www.wiseontech.com/hack/generating-rsa-keypairs-on-mac-os-x-for-a-nix-web-server#comments</comments>
		<pubDate>Sat, 22 Sep 2007 03:45:11 +0000</pubDate>
		<dc:creator>Jonathan Wise</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://software.jonandnic.com/hack/generating-rsa-keypairs-on-mac-os-x-for-a-nix-web-server</guid>
		<description><![CDATA[I'm sure there are many of you who have long been comfortable with RSA keypairs, so I post this as much for my own reference, as for those like me who stumble around the Internet trying to find coherent instructions on how to do this. These instructions work for OS X 10.4 -- not sure [...]]]></description>
			<content:encoded><![CDATA[<p>I'm sure there are many of you who have long been comfortable with RSA keypairs, so I post this as much for my own reference, as for those like me who stumble around the Internet trying to find coherent instructions on how to do this. These instructions work for OS X 10.4 -- not sure about other versions or *nixes. I plan to apply them to securing SSH on my iPhone for easier file transfers though.</p>
<p><strong>Step 1: Open Terminal</strong><br />
Usually found in the Utilities folder of Applications (but if you didn't know that already, this might not be the right topic for you!)</p>
<p><strong>Step 2: Create your public/private key pair on your <em>local</em> computer</strong></p>
<ul>
<li>At the command prompt type: <code>ssh-keygen -t rsa</code></li>
<li>Hit enter to accept the default file name and location</li>
</ul>
<p><strong>Step 3: Copy your public key contents into the "authorized_keys2" file on the remote server</strong>	</p>
<ul>
<li>Type: <code>ssh <em>username</em>@<em>remoteserver.com</em> 'cat &gt;&gt; ~/.ssh/authorized_keys2' &lt; /Users/<em>Youruser</em>/.ssh/id_rsa.pub</code></li>
<li>Enter your FTP password for the remote server when prompted
<ul>
<li>If the file didn't already exist on the remote server, it will be created, don't worry.</li>
</ul>
</li>
</ul>
<p><strong>Step 4: SSH at will!</strong><br />
You will never need a password from your account on your local computer again! Note that you'll need a public key provided for each client computer/computer account you want to use to connect to the server.</p>
 <img src="http://www.wiseontech.com/wp-content/plugins/feed-statistics.php?view=1&post_id=5" width="1" height="1" style="display: none;" /><img src="http://www.wiseontech.com/?ak_action=api_record_view&id=5&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.wiseontech.com/hack/generating-rsa-keypairs-on-mac-os-x-for-a-nix-web-server/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
