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.
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:
- Start with a copy of Raspbian on your SD card. You can install the Raspberry Pi imager, which makes it a painless process.
- 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
cdinto it, then
- Insert the SD card into your Pi, and connect the ethernet and microUSB cables to your laptop.
- 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”.
- 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.
- In your terminal, run
ifconfig, then find your bridge interface,
bridge100in my case, and get its network address under
- 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.
- 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.
sudo nmap -sS -p 22 192.168.2.1/24will list out all devices under this block.
- Simply SSH in! In my case,
ssh [email protected], with default password