I bought a raspberry pi as a smart home automation server. Here’s how to set it up without connecting a monitor, mouse or keyboard. All you need is an ethernet cable.
1. Prepare the SD card
- Download Raspbian from https://www.raspberrypi.org/downloads/raspbian/
- Copy it to the SD card, using
sshaccess for one start by creating an
sshfile in the
bash touch /Volumes/boot/ssh
- Eject the SD card (via the button in Finder or
diskutil eject /dev/disk2)
2. Prepare your Mac
You need to enabled Internet Sharing on MacOS so the Pi can connect to it. Go to System Settings > Sharing:
3. Configure SSH access
This assumes that you have an ssh key. If not or you don’t know what that is: An ssh key consist of two files: A private and a public one. The private one (
id_rsa) is on your computer and works like a password (so do not share it!). The public one (
id_rsa.pub) is on other computers and identifies you. It only works together with your private key, so don’t loose it. Your public key is on your computer as well so you can easily share it.
You can find both keys with
$ ls -l ~/.ssh total 120 -rw------- 1 jannikarndt staff 1766 Jan 3 2017 id_rsa -rw-r--r--@ 1 jannikarndt staff 403 Jan 3 2017 id_rsa.pub
If you don’t have a key, GitHub has a great article on how to create one.
Copy your ssh key to the pi:
cat ~/.ssh/id_rsa.pub | ssh email@example.com "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
SSH into the pi:
ssh firstname.lastname@example.org email@example.com's password: raspberry
The preconfigured password is
raspberry. A good reason to change it right away:
Change your root password:
Add your wifi credentials in
2 Network Options>
Permanently enable ssh access in
5 Interfacing Options>
And now, for the grand finale, you can (should / will want to) install a proper shell, i.e. oh my zsh:
sudo apt-get update && sudo apt-get upgrade sudo apt-get install git zsh chsh -s /bin/zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Great! Now you can use your Pi, for example