: O. Yuanying

iPhone に ssh で接続するよ

ssh to iphone

重い腰を上げる

iPhone の chroot jail から脱獄する方法が判明してからはや1ヶ月、ネイティブアプリがインストールできるようになって一週間。そしてついに iPhone 用 Terminal.app が公開されたと来たら、そろそろ傍観してるだけじゃすまなくなりました。

ということでまず最初に、iPhone に ssh で接続できるようにしてみた。

Install SSH on your iPhone

待っただけあって、iPhone に ssh をインストールする方法はかなり簡単になってる模様。

ツールのダウンロード

とりあえず Install SSH on your iPhone から簡単にsshをインストールするためのキットをダウンロードして解凍する。

Windows 版はエントリの本文中のリンクから、Mac 版はコメントからダウンロード可能。

jail break

chroot jail から脱獄しましょう。

解凍したディレクトリに移動して、jailbreakコマンドを実行。

[yuanying@Downloads]$cd iPhone\ SSH\ Install\ for\ Mac/
[yuanying@Cocoon iPhone SSH Install for Mac]$./jailbreak
[jailbreak 1.0] by ziel w/ special thanks to GeoHot and the rest of the #iphone-dev crew.

Looking for iPhone...
Sending Files...

*** If iTunes is running, please close it.
*** Hold the POWER and HOME buttons for approximately 25s.
*** Release when the display says 'Please Connect to iTunes'.

*** You're going to have to learn to hold it longer than that, buddy!


Sending More Files...
Booting iPhone...

Waiting for iPhone to finish booting...

Moving files into place...
Cleaning up...
Rebooting iPhone...

Enjoy your newfound freedom. Thank the devs at #iphone next time you see them for making this all possible.
p.s. Like most other useful tools, this one may be dangerous if used carelessly. Always remember -- You brick it, you bought it.

p.p.s. I have no idea how 'My Humps' could possibly have gotten set as your ringtone. ;)

途中で25秒間くらいパワーボタンとホームボタンを 'Please Connect to iTunes' という表示が出るまで押し続けろ、とか指令が出るので慎重に。

sshのインストール

コマンド一発とは行かないけれど、インストール用シェルスクリプトが公開されてるのでかなり簡単になった模様。

先ほどjail break したディレクトリで同じくiPhoneMacSSHInstall.shなるシェルスクリプトを実行する。

これまた途中で数回、iPhoneの再起動を要求されるので、言われるがままに再起動してやる。

[yuanying@Cocoon iPhone SSH Install for Mac]$./iPhoneMacSSHInstall.sh 
This shell script will install and enable a SSH server on your iPhone.
This script was created by Dallas Brown (http://www.kdbdallas.com)
This script was based off of Nate True's (http://cre.ations.net/blog) Windows script

Special thanks to all of the #iphone dev team.

--------PHASE 1: Getting files off your iPhone---------

iPhoneInterface v0.3.4 built on Jul 25 2007

Waiting for phone... established.
iPhone state: MismatchedICCID
type "help" for help
iPhone:/# iPhone:/usr/sbin/# fileref: 1
iPhone:/usr/sbin/# iPhone:/System/Library/LaunchDaemons/# fileref: 1
iPhone:/System/Library/LaunchDaemons/# 


--------PHASE 2: Uploading files and reconfiguring your iPhone---------

iPhoneInterface v0.3.4 built on Jul 25 2007

Waiting for phone... established.
iPhone state: MismatchedICCID
type "help" for help
iPhone:/# iPhone:/usr/sbin/# iPhone:/usr/sbin/# iPhone:/System/Library/LaunchDaemons/# iPhone:/System/Library/LaunchDaemons/# iPhone:/bin/# iPhone:/bin/# iPhone:/bin/# iPhone:/bin/# iPhone:/bin/# iPhone:/etc/# iPhone:/etc/# iPhone:/etc/init.d/# iPhone:/etc/init.d/# iPhone:/usr/bin/# iPhone:/usr/bin/# iPhone:/usr/bin/# iPhone:/usr/lib/# iPhone:/usr/lib/# iPhone:/usr/lib/# iPhone:/etc/dropbear/# iPhone:/etc/dropbear/# iPhone:/etc/dropbear/# 
--------PHASE 3: Restarting your iPhone---------

Press and hold the Power button on your iPhone until it shows the 'slide to turn off' red slider.
Slide it, wait for the phone to turn off, and press the power button to turn it on again.

Press Enter to continue...

--------PHASE 4: Putting init framework into place---------


mv: rename com.apple.update.plist.hackinit to com.apple.update.plist: No such file or directory

iPhoneInterface v0.3.4 built on Jul 25 2007

Waiting for phone... established.
iPhone state: MismatchedICCID
type "help" for help
iPhone:/# iPhone:/usr/sbin/# iPhone:/usr/sbin/# iPhone:/System/Library/LaunchDaemons/# iphoneinterface(6147,0xa000d000) malloc: ***  Deallocation of a pointer not malloced: 0x90b2f38c; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
iPhone:/System/Library/LaunchDaemons/# iPhone:/System/Library/LaunchDaemons/# 
--------PHASE 5: Restarting your iPhone, again---------

Restart your phone once more.  After that, you're done!

Press Enter to continue...

--------PHASE 6: Clean up----------

rm: com.apple.update.plist: No such file or directory

iPhoneInterface v0.3.4 built on Jul 25 2007

Waiting for phone... established.
iPhone state: MismatchedICCID
type "help" for help
iPhone:/# iPhone:/System/Library/LaunchDaemons/# iPhone:/System/Library/LaunchDaemons/# 

---------DONE!--------

Test connecting to your iPhone using ssh to see if this worked
ex: ssh -l root [IP Address]

Remember the root password is: dottie

Press Enter to Jail your iPhone or Ctrl-C to keep it free from jail  

iPhoneInterface v0.3.4 built on Jul 25 2007

Waiting for phone... 

established.
iPhone state: MismatchedICCID
type "help" for help
iPhone:/# iPhone:/System/Library/Lockdown/# iPhone:/System/Library/Lockdown/# 
Reboot your iPhone to finish the jailing process

./iPhoneMacSSHInstall.sh: line 105: unexpected EOF while looking for matching `"'
./iPhoneMacSSHInstall.sh: line 107: syntax error: unexpected end of file

Mac から接続してみる

iPhone の Settings から iPhone の IP アドレスを調べたら、ssh で接続してみる。

root のパスワードはdottie

[yuanying@Cocoon yuanying]$ssh 192.168.1.10 -l root
root@192.168.1.10's password: 
-sh-3.2# pwd
/var/root
-sh-3.2# echo $PATH 
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
-sh-3.2#

まあ素敵!