How I use my iPad to write code
I write code day to day on my iPad. Not in my workplace, but when I’m on the train or making quick fixes at home or even from a coffee shop I can whip out my iPad, tether to my phone and start fixing things.
I can do this with no lag (through a tool called mosh, which gets around the typical SSH lag you see due to the ssh protocol requiring round-tripping before displaying output a.k.a typing and not seeing any output.)
I use an iPad Pro 10.5 inch with a Smart Keyboard but any recent-ish iPad can achieve the same results.
The iOS tools to use ssh are specialist, niche pieces of software. If you hear niche software and think “pricey” you’d be totally right. The two main contenders for using SSH on iOS are;
- Prompt 2 by Panic
- Blink by The Blink Shell Project
And they cost £14.99 and £19.99 respectively. That is expensive for an iOS app, but they are complex pieces of software that are developed by highly talented developers.
Using your iPad the way I do moves computation to subscription model. Many people are unhappy with that and like having fixed costs for their computation. My typical usage is to try out new languages and learn stuff so I use a t2.micro with 1gb ram / 10gb SSD which is free to use. If I wanted to do some ML training I could spin up a larger EC2 instance or use something like Google Cloud TPU, get the model and continue writing code on the smaller, free instance.
I personally like the idea that my computation processing potential isn’t bounded by a one time fixed-cost but it’s something I can pay more for as and when I need it.
If that sounds like something attractive to you, move on to the next step.
First we set up an EC2 Instance. EC2 is a hosted VM service provided by Amazon through their AWS service. The free tier allows for 750 hrs of computer time per month (750/24hrs = 31.25 days - So it always free, given you don’t scale up the hardware, up to you). You can install a few different flavours of Linux or even Windows on an EC2 Instance. For the purpose of this tutorial we are going to install Red Hat Enterprise Linux. RHEL is a hardened and stable OS with support all your dev tools.
Setting up free EC2 instance
First sign up for an AWS account if you don’t already have one. Select the free tier for now. ![LINK TO AWS].
Once setup go to the dashboard and select EC2. Once there select the free tier t2.micro box with 2GB RAM and 10GB HDD.
![IMAGE OF DASHBOARD]
If you need more power, you can scale these boxes up as and when needed. The free tier is fine for installing tools and writing code. When it comes to doing heavy tasks, start up an instance with more RAM, Higher clock speed and only use it when needed and then shut it down. That way you can save money.
After it starts up you can move on to the next step.
Setting up ssh keys
[LOCAL DEVICE] - If you have a private key pair in your .ssh folder, go ahead and copy the RSA.pub onto your EC2 instance under known hosts.
[iPad] - [BLINK] Open the app, press
Cmd + , and select SSH Keys and generate key. Copy the key.
[EC2] - SSH onto your EC2 Instance and copy your SSH key into the
Setting up mosh on server
![STEPS FOR HOW TO SSH ON]
Once you have your EC2 instance setup with the key you can connect to your box. Now you need to install Mosh. Mosh stands for Mobile Shell and it enables for a more stable connect than SSH can, especially when you are on a mobile network like 3G.
Once you’ve connected run the command;
sudo yum install mosh
If a prompt comes up to ask you about installing this tool and how much space it will take, press
Y to confirm the installation.
That’s it you don’t need to do anything to get mosh running, the tool will handle connections for you when you attempt a connection from another device.
Opening up port for SSH/Mosh on your EC2 Instance
In order to enable connections to the EC2 instance you need to open a port that will allow other devices to connect to it over TCP/IP. To do that you need to go back to the AWS dashboard > EC2 > Running Instances.
Now select your running instance and select ![PROCESS OF OPENING PORT]
mosh ec2user@<YOUR_INSTANCES_IP> -p 60001 from the Blink app and you’ve connected. Congrats!
If you need a Desktop you can install a desktop environment on your EC2 instance and use the Screens app to connect via VNC. No mouse support for iPad will probably make this a pain to use.