You need a jailbroken iPhone for this.

  1. use Cydia to install the OpenSSH package
  2. enable WLAN access and find your iPhone's IP (see Settings → Wi-Fi → \<Your Network SSID> → IP Address)
  3. under Linux type: ssh <IP address> -l root; for Windows use PuTTY
  4. (the first connection will need about 20-30 seconds1 before you'll be asked to accept the host key)
  5. use the following password: alpine (older iPhones used dotty)

  1. most probably the iPhone will generate some encryption keys here