Difference between revisions of "Enable SSH Without Opening the Apple TV"

From AwkwardTV
Jump to: navigation, search
(New page: ==Parts Needed== *External USB Drive *partition.img repair.img and efi.img from an apple tv drive ==The Steps== <font color=red>I AM WAITING FOR SOMEONE TO DO A SECONDARY CONFIRMATION PLE...)
 
(Undo revision 5034 by Special:Contributions/Sabor (User talk:Sabor))
 
(30 intermediate revisions by 13 users not shown)
Line 1: Line 1:
 
==Parts Needed==
 
==Parts Needed==
*External USB Drive
+
*External USB drive
*partition.img repair.img and efi.img from an apple tv drive
+
*boot.efi from appletv.  
 +
  MD5SUM: 280323d8700e4cfef15116f7e50590e3  boot.efi  
 +
  (got it from the recovery image ''Zuo'')
 +
*licensed copy of os x for intel
 +
*usb hub w/ external power
  
==The Steps==
+
==Instructions==
<font color=red>I AM WAITING FOR SOMEONE TO DO A SECONDARY CONFIRMATION PLEASE REMOVE THIS NOTE IF YOU HAVE CONFIRMED</font>
+
<font color=red>THE METHOD DESCRIBED BELOW ASSUMES THE USB DRIVE OR IPOD YOU ARE INSTALLING TO IS EMPTY AND HAS NO DATA THAT YOU CARE ABOUT.  PLEASE USE CAUTION</font>
We are going to modify the repair image and the os that it installs when you factory reset
 
  
# Mount repair.img on your Intel Mac OS desktop/laptop
+
== Step 1 ==
# Convert the existing OS.img to one that is writeable:
+
Install full Mac OS X onto the device, using semthex's kernel and instructions detailed here: [http://www.appletvhacks.net/2007/04/01/mac-os-x-running-on-apple-tv/ Apple TV Hacks - Mac OS X running on Apple TV]. If you want to avoid having to use a keyboard and mouse through a USB hub later, boot up the installation before you change the kernel and activate SSH and/or Remote Desktop/VNC server in the Sharing preference pane.
hdiutil convert -format UDRW -o RW.dmg /Volumes/Recovery/OS.dmg
+
 
#Mount the new RW.img
+
If you're installing to a small device you'll want to read the instructions for a minimal install [[Patchstick/Testing|Here]].
#Copy sshd and the plist file onto the new OSBoot you created
+
 
cp /System/Library/LaunchDaemons/ssh.plist /Volumes/OSBoot/System/Library/LaunchDaemons/ssh.plist
+
== Step 2 ==
  cp /usr/sbin/sshd /Volumes/OSBoot/usr/sbin/sshd
+
Modify the AppleFileSystemDriver, add this text to the file <tt>/System/Library/Extensions/AppleFileSystemDriver.kext/Contents/Info.plist</tt> in the IOPropertyMatch array section.  This can be done easily in the Finder with the TextEdit application.<br>
#Convert the new RW.img back into a readonly compressed image
+
<pre>
hdiutil convert -format UDZO -o NEWOS.dmg RW.dmg
+
&lt;dict&gt;
#Copy the NEWOS image onto the repair image cp NEWOS.dmg /Volumes/Recovery/OS.dmg
+
        &lt;key&gt;Content Hint&lt;/key&gt;
unmount the recovery image
+
        &lt;string&gt;5265636F-7665-11AA-AA11-00306543ECAC&lt;/string&gt;
#Now we are going to setup the external drive:
+
        &lt;key&gt;Leaf&lt;/key&gt;
dd if=partition.img of=/dev/disk# bs=1024k count=100
+
        &lt;true/&gt;
  dd if=EFI.img of=/dev/disk#s1
+
&lt;/dict&gt;
  dd if=repair.img of=/dev/disk#s2
+
&lt;dict&gt;  
#plug in the usb drive to the appletv after its booted
+
        &lt;key&gt;Content Hint&lt;/key&gt;
#press menu and - on the remote
+
        &lt;string&gt;Apple_Recovery&lt;/string&gt;
#then run factory restore
+
        &lt;key&gt;Leaf&lt;/key&gt;
 +
        &lt;true/&gt;
 +
&lt;/dict&gt;
 +
</pre>
 +
<b>Very special thanks to [http://0xfeedbeef.com/appletv/ Turbo] for this patch</b>. If you skip this step then OSX won't boot and will complain that it is waiting for the root device<br>
 +
 
 +
== Step 3 ==
 +
Now we are going to change the partition info to that of a recovery system. This requires the use of the Terminal application. <font color=red>It is imperative that you ensure you are working with the proper disk.</font>  If you have only one internal hard disk in your system and the disk you want to modify is your only external disk, then it will likely be identified as <tt>/dev/disk1</tt>.  To make sure, type <tt> diskutil list</tt> at the command prompt to see all disks attached to your system.
 +
 
 +
Then, assuming <tt>/dev/disk1</tt> is the correct disk,  using the command <tt>sudo gpt show /dev/disk1</tt>  should get results such as these:
 +
<pre>
 +
      start      size  index  contents
 +
          0          1        PMBR
 +
          1          1        Pri GPT header
 +
          2        32        Pri GPT table
 +
        34          6       
 +
        40    409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
 +
    409640  116538416      2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
 +
  116948056    262151       
 +
  117210207        32        Sec GPT table
 +
  117210239          1        Sec GPT header
 +
</pre>
 +
Where <tt>index 1</tt> is the EFI partition and <tt>index 2</tt> is the Mac OS X installation.
 +
 
 +
<font color=red>THE FOLLOWING INSTRUCTIONS ASSUME <tt>/dev/disk1</tt> IS YOUR EXTERNAL DRIVE. YOU CAN BREAK YOUR SYSTEM IF IT ISN'T.</font>
 +
 
 +
First unmount the disk. Otherwise you will get a 'Resource busy' error.
 +
 
 +
<pre>
 +
disktool -u disk1
 +
</pre>
 +
 
 +
Now do this to set up the drive to work as a recovery partition:<br>
 +
<pre>
 +
gpt remove -i 2 /dev/disk1
 +
</pre>
 +
Then take the numbers from above and plug them in respectively, for me the start point is 409640 and the size is 116538416<br>
 +
<pre>
 +
gpt add -b 409640 -i 2 -s 116538416 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/disk1
 +
</pre>
 +
 
 +
== Step 4 ==
 +
Remove the drive from your Mac and connect it to the Apple TV. If you didn't activate SSH or Remote Desktop/VNC, use a USB hub so you can also connect a keyboard and mouse. Reboot the Apple TV by pressing and holding the 'menu' and '-' buttons simultaneously on the Apple remote until the reboot occurs. If you activated SSH and Remote Desktop/VNC, just log in when the Apple TV is done booting.
 +
 
 +
The ATV OS is on the partition labled 'OSBoot'. Instructions for enabling SSH are located [http://wiki.awkwardtv.org/wiki/Install_SSH here].  I used [http://phoem.com/appletv-install.sh appletv-install.sh] to copy the necessary files (<tt>gdb</tt> will probably fail, that is ok you can ignore it).  Be sure to enable ssh on your Mac OS X install before you run this script so that it copies the <tt>ssh.plist</tt> file that has sshd enabled and not disabled.
 +
 
 +
 
 +
The below is redundant, apparently you can also use mount_hfs to mount your partition, but I have documented success using the below method also - MrZ
 +
 
 +
If you mess up and want to mount your "repair" partition again, you can just reverse the steps, but change
 +
 
 +
<pre>
 +
gpt add -b 409640 -i 2 -s 116538416 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/disk1
 +
 
 +
to
 +
 
 +
gpt add -b 409640 -i 2 -s 116538416 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk1
 +
</pre>
 +
 
 +
The repair partition shows up again on your machine, and you can edit it.
 +
 
 +
==References==
 +
*[http://0xfeedbeef.com/appletv/usbboot http://0xfeedbeef.com/appletv/usbboot]
 +
*[http://phoem.com/appletv-without-open.html http://phoem.com/appletv-without-open.html]
 +
 
 +
[[Category:How-to]][[Category:Software]][[Category:Hardware]]

Latest revision as of 09:49, 21 September 2007

Parts Needed

  • External USB drive
  • boot.efi from appletv.
  MD5SUM: 280323d8700e4cfef15116f7e50590e3  boot.efi 
  (got it from the recovery image Zuo)
  • licensed copy of os x for intel
  • usb hub w/ external power

Instructions

THE METHOD DESCRIBED BELOW ASSUMES THE USB DRIVE OR IPOD YOU ARE INSTALLING TO IS EMPTY AND HAS NO DATA THAT YOU CARE ABOUT. PLEASE USE CAUTION

Step 1

Install full Mac OS X onto the device, using semthex's kernel and instructions detailed here: Apple TV Hacks - Mac OS X running on Apple TV. If you want to avoid having to use a keyboard and mouse through a USB hub later, boot up the installation before you change the kernel and activate SSH and/or Remote Desktop/VNC server in the Sharing preference pane.

If you're installing to a small device you'll want to read the instructions for a minimal install Here.

Step 2

Modify the AppleFileSystemDriver, add this text to the file /System/Library/Extensions/AppleFileSystemDriver.kext/Contents/Info.plist in the IOPropertyMatch array section. This can be done easily in the Finder with the TextEdit application.

<dict>
        <key>Content Hint</key>
        <string>5265636F-7665-11AA-AA11-00306543ECAC</string>
        <key>Leaf</key>
        <true/> 
</dict> 
<dict>  
        <key>Content Hint</key>
        <string>Apple_Recovery</string>
        <key>Leaf</key>
        <true/> 
</dict> 

Very special thanks to Turbo for this patch. If you skip this step then OSX won't boot and will complain that it is waiting for the root device

Step 3

Now we are going to change the partition info to that of a recovery system. This requires the use of the Terminal application. It is imperative that you ensure you are working with the proper disk. If you have only one internal hard disk in your system and the disk you want to modify is your only external disk, then it will likely be identified as /dev/disk1. To make sure, type diskutil list at the command prompt to see all disks attached to your system.

Then, assuming /dev/disk1 is the correct disk, using the command sudo gpt show /dev/disk1 should get results such as these:

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  116538416      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  116948056     262151         
  117210207         32         Sec GPT table
  117210239          1         Sec GPT header

Where index 1 is the EFI partition and index 2 is the Mac OS X installation.

THE FOLLOWING INSTRUCTIONS ASSUME /dev/disk1 IS YOUR EXTERNAL DRIVE. YOU CAN BREAK YOUR SYSTEM IF IT ISN'T.

First unmount the disk. Otherwise you will get a 'Resource busy' error.

disktool -u disk1

Now do this to set up the drive to work as a recovery partition:

gpt remove -i 2 /dev/disk1

Then take the numbers from above and plug them in respectively, for me the start point is 409640 and the size is 116538416

gpt add -b 409640 -i 2 -s 116538416 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/disk1

Step 4

Remove the drive from your Mac and connect it to the Apple TV. If you didn't activate SSH or Remote Desktop/VNC, use a USB hub so you can also connect a keyboard and mouse. Reboot the Apple TV by pressing and holding the 'menu' and '-' buttons simultaneously on the Apple remote until the reboot occurs. If you activated SSH and Remote Desktop/VNC, just log in when the Apple TV is done booting.

The ATV OS is on the partition labled 'OSBoot'. Instructions for enabling SSH are located here. I used appletv-install.sh to copy the necessary files (gdb will probably fail, that is ok you can ignore it). Be sure to enable ssh on your Mac OS X install before you run this script so that it copies the ssh.plist file that has sshd enabled and not disabled.


The below is redundant, apparently you can also use mount_hfs to mount your partition, but I have documented success using the below method also - MrZ

If you mess up and want to mount your "repair" partition again, you can just reverse the steps, but change

gpt add -b 409640 -i 2 -s 116538416 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/disk1

to

gpt add -b 409640 -i 2 -s 116538416 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk1

The repair partition shows up again on your machine, and you can edit it.

References