Raspberry Pi and VS Code Remote Explorer (via SSH)
TLDR: I bought a Raspberry Pi, SSH into it, and write code and various scripts. I use the VS Code Remote Explorer to open up the files on the Pi as if they were on my machine! I provide a quick guide on how to set it up!
I bought a Raspberry pi over the 2022 holidays. My inspiration for doing so was a mix between wanting to have a small computer to run periodic automations, wanting a fun project that I can hack on with whimsy, and removing the irritation for paying $5/mo for cloud compute for what would essentially be the same thing as a Pi.
Fortunately, I was able to get one of the Raspberry Pi 4 8GB kits! Even though it came with a 128GB SD card, I had a 256GB card lying around that I used instead of the one from the kit.
Setup was actually rather easy — if you set up as well, I'd recommend using an ethernet cable since downloading the OS over Wifi is pretty slow.
So here's a simple guide for setting it up:
- Before you begin, I assume you've already setup your Raspberry Pi and have connected it to a monitor / keyboard / mouse as per the setup instructions that came with your Pi. You'll need to have it connected to a monitor for the next step.
- Enable your Raspberry Pi to receive SSH connection over your local network. I used this quick guide. This is a pretty straightforward guide on how to enable your Raspberry Pi to be accessible via SSH within your local network. If you want to make your PI accessible outside your local network, you'll need to do some additional steps. You'll also want to write down the local IP address, which you can find using this guide.
- Via your command line, SSH into your Pi. should be something like
ssh email@example.com.Xwhere X is likely to be different based on your local network. It also probably depends on your router as well. You can learn more about that here. You want to make sure that you can access your Pi from the device you want to use VS Code Remote Explorer.
- [Optional] After you connect via command line first, you can add your machine's public ssh key to the
authorized_keysfile so you don't need to put in your password each time! This guide should explain how to do it easily. This is nice to do because otherwise VS Code would prompt you to put in the password each time it wants to connect via SSH. This is great if you want to SSH into your Pi from multiple computers (I use both my personal Mac and gaming PC to SSH in, depending on what I'm feeling).
- Add VS Code Remote Explorer Plugin
- Add your Pi! You can either do this by editing your
~/.ssh/configfile to add it as a host, or manually adding the Pi as a host via the UI in VS Code.
- Connect to your host and you're done!
- [Optional] Generate an ssh key on the Pi and add it to your Github, so you can read and write to your repos from your Pi.
Happy hacking! Perhaps in a future article I'll write about what I'm using my Pi for. Let me know if there's anything interesting I should do 😄