blog.cyrusroshan.com

25 October 2020

No. 8

Two cable SSH: the fastest Raspberry Pi setup

Fiddling with monitors is annoying. This method lets you get an SSH connection to your Pi without having to connect it to a monitor, find an external keyboard, or manually type in your wifi password.

Simple and portable enough that you could do the entire process at a cafe

Taking out the manual process and sending everything over the wire makes it much easier to automate initial config, and I found it very useful when setting up my home servers with Ansible.

The two-cable SSH

Here's how to do it with a macOS host:

  1. Start with a copy of Raspbian on your SD card. You can install the Raspberry Pi imager, which makes it a painless process.
  2. Re-insert the SD Card, then create an empty file named "ssh" into its boot partition. This should be the partition that auto-mounts, so you can simply cd into it, then touch ssh.
  3. Insert the SD card into your Pi, and connect the ethernet and microUSB cables to your laptop.
  4. Open System Preferences and go to the Sharing tab. Enable internet sharing through your ethernet port. If you're using an adapter, your ethernet port may be called by the adapter name, such as "USB 10/100 LAN".
  5. Open System Preferences, and go to the Network tab. Enable DHCP or DHCP with manual address on your ethernet port. Wait for it to get connected.
  6. In your terminal, run ifconfig, then find your bridge interface, bridge100 in my case, and get its network address under inet.
  7. Usually, you can just assume the Pi's IP address will be allocated to the next IP bridge interface's IP + 1. In my case, this is 192.168.2.1 + 1, so 192.168.2.2.
  8. Or to be really sure, you can find the Pi's IP by scanning the range of IP addresses in your subnet.
    • In my case, my bridge interface address is 192.168.2.1 and mask is 0xffffff00, which is a /24 block.
    • So sudo nmap -sS -p 22 192.168.2.1/24 will list out all devices under this block.
  9. Simply SSH in! In my case, ssh [email protected], with default password raspberry.
Get new indie blog posts in your mailbox, personally written by me