5 minutes
Raspberry Shell
Raspberry Shell
I’ve had some interest in how I use a Raspberry Pi as a portable backend and shell for my iPad. You can use this method with any device that can give you a shell over ssh (Android, your iPhone, a Mac or Windows machine, etc.). The TL;DR is that I use a RPi and shell into it so I can perform certain tasks while on my iPad. That may sound simple or obvious. If so, skip the remainder of this post and get back 10-15 minutes of your time.
The Problem
In brief, I’m a shell person. I interact with computers best via a command-line prompt. It’s fast, and many tools only exist in this realm.
Cloud-based shells are increasingly popular, and I have access to several, however, I may often be in a location where I just don’t have connectivity for some reason. Finally, it’s nice to have a (small) machine that just travels with me, and can provide a home base.
My Setup
This is the setup that I use, and is one that you may wish to expand on. My current setup is:
- Raspberry Pi 4
- A Portable Battery
- Portable/Travel Router
Let’s start with the latter items and leave the RPi for last.
Battery
I can’t point you to the exact battery or travel router that I use as they’re no longer made. I don’t even use the same battery all of the time. If you have a battery that can output 10,000mAh or more, it’ll keep you going for a full day. I’d point you to this particular Anker PowerCore because a) it’s small but powerful enough, b) Anker makes quality products that have never let me down, and c) the two USB outputs. So, you may already have this component. If not, grab the Anker and move along.
Travel Router
I love having a travel router when out of the house for a lot of reasons. They’re great on a train or plane, or even in coffee shop. All of those uses aside, it’s critical in this scenario. It’s how you’ll be able to consistently connect to the RPi. As mentioned, the travel router that I use is an older TP-Link that is no longer made. It’s been good to me, so, I’d have no hesitation in just buying the one I linked above. It has a simple web-based interface to configure everything. If you’re looking for something a little more hackable, with built-in VPN, I’d point you at GL-iNet’s Slate.
If you’re really ambitious, of course, you could make your own travel router out of a Raspberry Pi :-)
Raspberry Pi
It would be easy to tell you to just get the biggest, fastest thing you can, but that may or may not be the right advice. I’m using a Raspberry Pi 4 Model B with 4GiB of RAM. It’s too bad I won’t be using any of the fancy video options on this model (dual 4k monitor support?!?).
To keep things portable, I’ve just dropped in a 128GiB SD card, used for boot and storage. It’s definitely not the fastest way to handle files on disk, but it’s the tradeoff I’m willing to make. If you want more performance, many people don’t realize that RPi machines can use an external SSD over USB. That’s an enormous upgrade if you can deal with the extra device. Maybe you even take a hybrid approach and connect an SSD as needed. I find the CPU power of the RPi 4, the 4GiB of RAM, along with GB WiFi/Ethernet the right balance for my needs.
After a bit of looking at various distros, I’m running Raspbian as the OS.
Configuration
Since my goal is to never connect the RPi to anything more than power, right after flashing Raspbian to the SD card, I make these changes so I can manage everything, including the initial boot, completely headless:
Radiotope: Raspberry Pi Headless Config
Once it’s booted and you’re ssh-ed in, run the initial config on the RPi, apt-get update all the things (and ideally install mosh and screen/tmux). Meanwhile, go set up that fancy new travel router.
The travel router will give you your own private network. Choose an address range that you’re happy with, and make sure the RPi consistently connects to it. Use the output from ifconfig, grab your interface’s MAC address, and use it to have the travel router assign a static IP address.
iOS now has a number of wonderful shell-like environments that support ssh (or even better: mosh!). Look at Blink Shell and iSH from this post on Things I Use. I prefer using mosh where possible as it’s so easy to close the lid on your Mac or iPad, move around, and still be connected and right where you left off when you return. (It’s also painfully easy on iOS to background your shell, take slightly too long, and let iOS drop the process. mosh lets me keep my Zen-like composure.)
Fin
That’s really all there is to it. You can configure your RPi however makes sense to you. Install a text editor. Get the language of your choice on there—particularly something like Rlang or Go which don’t have an environment on iOS, whereas languages like Python kind-of do.
If you’re into Go, you no longer need to compile it yourself, just a straight-forward apt-get install golang
. You can even install and run Docker (TL;DR - curl -sSL https://get.docker.com | sh
)
Enjoy - and I hope this helps you think differently about approaches to augmenting your setup. I’d love to hear what you come up with!
936 Words
2020-01-01 00:00