Skip to content

Instantly share code, notes, and snippets.

@dzanaga
Last active December 19, 2024 11:30
Show Gist options
  • Select an option

  • Save dzanaga/286488ee6c2a9ed43c3bdc334397629f to your computer and use it in GitHub Desktop.

Select an option

Save dzanaga/286488ee6c2a9ed43c3bdc334397629f to your computer and use it in GitHub Desktop.

Prepare SD card

  1. Download imager from https://www.raspberrypi.org/downloads/ / sudo apt install rpi-imager -y

  2. Install Raspbian lite on the SD. For newer >Bookworm click on the gear and setup WiFi and ssh from the imager. Bookworm doesn't use wpa_supplicant.conf

I had issues. So i connected via WiFi, enabled wifi with sudo raspi-config. Then generated a pair key, copied to the client, set 600 for key and 644 for pub and was able to passwordless ssh via wifi.

To manage static IP and DNS:

sudo nmcli c mod telenet-81BD3_EXT ipv4.addresses 192.168.0.3/24 ipv4.method manual
sudo nmcli con mod telenet-81BD3_EXT ipv4.dns "8.8.8.8 1.1.1.1"

Before Bookworm: 3. Add a wpa_supplicant.conf file to the boot partition. Set the return line to LF for unix systems. See: https://www.raspberrypi.org/documentation/configuration/wireless/headless.md Example:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>

network={
 ssid="<Name of your wireless LAN>"
 psk="<Password for your wireless LAN>"
}
  1. Enable SSH See: https://www.raspberrypi.org/documentation/remote-access/ssh/README.md Add an empty ssh file to the boot partition with no extension.

SSH into the Pi

  • Boot the pi with the sd card.
  • Find the pi address with an app like Fing on your smartphone
ssh pi@192.168.0.144
  • Default password is raspberry. After logging in, change it using passwd.
  • Buster comes with Python 3.7, you can change the default python symbolic link to use python3 instead of python2.
sudo unlink /usr/bin/python
sudo ln -s /usr/bin/python3 /usr/bin/python

Passwordless sudo

sudo visudo

add

%sudo         ALL = (ALL) NOPASSWD:ALL

Upgrade

sudo apt update && sudo apt -y upgrade

Install Jupyter

Follow https://github.com/dzanaga/jns

Fixed ip

sudo nano /etc/dhcpcd.conf

add:

interface wlan0
static ip_address=192.168.0.2/24
static routers=192.168.0.1
static domain_name_servers=8.8.8.8 8.8.4.4

Passwordless ssh

On the client, generate a key pair with ssh-keygen. The create an entry for the pi in the ssh config .ssh/config:

Host pi
  HostName 192.168.0.2
  User pi
  Port 22
  IdentityFile /home/daniele/.ssh/id_rsa

Host piTunnels
  HostName 192.168.0.2
  User pi
  Port 22
  LocalForward 18888 localhost:8888
  IdentityFile /home/daniele/.ssh/id_rsa
  ServerAliveInterval 30
  ServerAliveCountMax 3

Finally add the public key to the authorized keys:

cat .ssh/id_rsa.pub | ssh pi 'cat >> .ssh/authorized_keys'

Auto ssh for permanent tunnels

Install autossh on your client: sudo apt-get install -y autossh

Run: autossh -M 0 -f -T -N piTunnels

OctoPi

In the boot partition set:

  • octopi-wpa-supplicant.txt:

  • octopi.txt:

camera="raspi"
camera_raspi_options="-x 1280 -y 720 -fps 5 -quality 100 -rot 180"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment