About
Contact
Feedback
Clients
Reviews
Articles

HOWTO: SSH via O2 PAYG HTTP Proxy on the iPhone

By Richard Bland, Combined Effort Consulting, 17 Jun 2008.

Overview

This article will concentrate on getting SSH working via O2's PAYG HTTP Proxy on the iPhone over GPRS. However, the information here can be used for other networks (EDGE, 3G) and platforms, assuming a version of corkscrew is available for that platform.

Caveats

The main caveat here is that the target SSH server must be listening on port 443, typically reserved for HTTPS. I haven't tried this workaround on the standard port (22), since I've always tended to run SSH on 443 in order to circumvent firewall rules. Since the version of corkscrew used here is compiled using the non-Apple toolchain, you may require an unlocked iPhone, too.

Background

With the rise of unlocked iPhones, there came the possibility of hooking the phone into the UK PAYG networks. This made the phone much more attractive, since a sealed, 1st generation phone could be bought on eBay for around £280 (December 2007), unlocked and a PAYG SIM card inserted. This is compared to £269 + (18 month contract @ £35) = £899 when the phone was released in the UK.

Once on a PAYG network, the challenge was procuring Internet access at reasonable cost. This has become more accessible with packages such as O2's Web Bolt-on, currently priced at £7.50 a month for 200MB. This gave 'Internet' access, but appears to only support HTTP and even that has to go through a proxy, which requires some configuration on the iPhone, with changes required to /Library/Preferences/SystemConfiguration/preferences.plist and the creation of a proxy.pac file.

The 'final' challange comes from trying to get SSH working. Since the O2 HTTP Proxy doesn't support SSH, the protocol has to be tunnelled over HTTP and this functionality is provided by a great program called corkscrew. However, corkscrew requires compiling for the target platform, so a cross-platform toolchain was compiled and installed based on instructions on the iphone-dev website. Once that was in place, it was simply a case of unpacking corkscrew and compiling using the toolchain:

$ arm-apple-darwin-gcc -c -fsigned-char -Wall -Werror -O7 -c corkscrew.c
$ arm-apple-darwin-gcc -Wl,-syslibroot,/usr/local/share/iphone-filesystem \
                     -lobjc -o corkscrew  corkscrew.o

Downloadable Files

The end result of all of the above is a corkscrew executable for the iPhone platform. This was built against a 1.1.4 firmware filesystem, but may be usable with other versions. It needs to be copied to the file /private/var/mobile/corkscrew on the iPhone. The executable was created from vanilla corkscrew 2.0 from the corkscrew homepage. I've also included the .ssh/config file, detailing the proxy command needed for ssh.

About the Author
Richard Bland is the Senior Software Engineer at Combined Effort Consulting Limited. Richard is based in Leicester, UK and has worked in the IT Industry for over 10 years, specialising in Database, Web and Win32 development.