One of the most important things the iPhone hacker groups provide (since I'm fine with AT&T service) is Nullriver's AppTapp, and two of the most important packages it provides are terminal emulators (I currently use Terminal-vt100 because it if you drag on the top of the screen it provides a donut with arrow keys and a few Control keys). I certainly hope AppTapp isn't destroyed as collateral damage when Apple attacks the non-AT&T activation efforts.

Does anyone know how to get generic control keys out of any of the iPhone terminal emulators? Obviously Apple doesn't provide a Control key on its stock keyboard layouts...

I was surfing around and found Craig Hockenberry's Hacking Quicker. I noticed it doesn't match what I see, and realized this is apparently because earlier versions of the "OpenSSH" package installed by AppTapp were not actually OpenSSH. Now that this has been cleared up, the procedures for conveniently sshing into the iPhone are different than Craig described -- note that you should not start by installing the OpenSSH package, as this makes your iPhone vulnerable to miscreants:

On the Mac

  1. From the Mac, install AppTapp if necessary.
  2. On the Mac (or Linux system, etc.), if you don't already have an ssh keypair, create one with "ssh-keygen -t rsa" -- this creates ~/.ssh/id_rsa & ~/.ssh/ For convenience, use anssh` keychain program to avoid re-entering your private key's encryption passphrase on every use, such as SSHKeychain.

On the iPhone

  1. From Installer (AppTapp), install a terminal program (I use Terminal-vt100).
  2. Launch the terminal program.
  3. In the terminal, type "passwd root". Then enter the new password twice. If it doesn't work, try again.
  4. In the terminal, type "passwd mobile". Then enter the new password twice. If it doesn't work, try again. Note that you can use the same password for mobile and root.
  5. From Installer, install OpenSSH now.
  6. "ssh YourMacIPAddress". Log into your Mac, and type "echo $SSH_CLIENT"; this is your iPhone's IP address. Setting up your iPhone to get a consistent IP address is beyond the scope of this article, but makes connecting to it much easier. If that's not feasible, you can either hit an unused URL and check the web server logs to find the client IP.

On the Mac

  1. "ssh root@iphone" (substitute your iPhone's IP address from the previous step for iphone). This will take a while the first time (~~35 seconds)
  2. Enter the root password you set previously.

From the Mac keyboard, logged into the iPhone

  1. Browse around the iPhone -- isn't it easier with a full keyboard, and Copy & Paste?
  2. mkdir ~/.ssh
  3. chmod go-w / ~
  4. This one must be exactly right, or you could trash your sshd_config -- note the double greater-than symbols: "echo AuthorizedKeysFile .ssh/authorized_keys >> /etc/sshd_config".

On the Mac (in a new Terminal window)

  1. scp ~/.ssh/ root@iphone:.ssh/authorized_keys
  2. ssh root@iphone

If everything worked right, this last command will provide a root shell on the iPhone based on your ssh keys, not your UNIX-style password on the iPhone (it can be difficult to tell the difference if you use the same passphrase for your ssh private key as for the iPhone's root account). If you use an ssh keychain, you shouldn't need to provide a password each time you ssh into the iPhone.