I recently got an iPad and I’d like to use it to write some code. I found the app a-Shell was the best way to get code running locally on my iPad. The terminal app provides custom builds of Python, C, Vim, git, ssh: most of the things you need to get started. But I was still frustrated by the limitations. What I really wanted was VSCode and the ability to install and build any software.
My plan was to use my Windows 10 PC as a server that hosted VSCode, and connect to that server with the iPad so I could use VSCode in the browser. I found this tweet to be a nice overview of ssh as I was trying to set everything up.
Windows Setup
First, I installed Windows Subsystem for Linux (WSL) 2:
- run powershell as administrator
wsl --install
Next, I need to setup my PC as a server. Luckily, Windows 10 now comes with the ability to install OpenSSH directly. This tutorial got me most of the way there.
I also found that setting up the private keys was a little tricky.
You’ll have to edit ssh_config
to find the location of
ssh\administrators_authorized_keys
.
Here are two resources I found useful:
- https://serverfault.com/questions/1032713/public-key-authentication-not-work-on-windows-10-professional
- https://jmmv.dev/2020/10/windows-ssh-access.html
WSL
On WSL, you’ll now need to install code-server to host VSCode.
The major limitation with WSL is that it doesn’t have systemctl
, or at least
not in the same way as normal Ubuntu. There are ways to get around
this limitation, but I ended up ignoring it and deploying
the service manually each time I ssh’d into the machine. I’ll
explain more in the iPad section.
Lastly, I recommend installing Git on Windows for WSL if you haven’t already. This is not strictly needed to ssh onto the machine, but you’ll want it setup so you can use git as you would normally.
It’s also a good time to set it up with a credential store:
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-store.exe"
iPad
Next, you’ll need an app to ssh to the machine. You can use a-Shell as I recommended before, but my favorite app is Terminus.
Terminus is the most useful app for ssh, because it allows you to turn on location services. This seems strange at first, but by turning location services on, it prevents the ssh connection from ending while you switch between apps.
Next, inside Terminus, you’ll need to connect to your server
(whoami
and ipconfig
on the Windows machine will help you find
your IP address) and you’ll need to setup your ssh key.
If the connection was successful, you should see the bash shell (or powershell if you didn’t customize the default shell. If in powershell, just run `bash.exe).
From there, if code-server is installed correctly, all you need to do is type in code-server
to deploy your VSCode server. Since we didn’t
setup a service manager, you’ll need to run this each time you connect
via ssh. It didn’t bother me too much so I left it as is, but there
are ways to get around this. For example: https://stackoverflow.com/questions/55579342/why-systemd-is-disabled-in-wsl
In Terminus, setup portforwarding to 8080. That way when you visit http://localhost:8080
in Safari, you’ll be connected to VSCode!
In Safari, you can also click on Share, Add to Homescreen to create a
VSCode app.