xyzarivera / glitch-diary

1 stars 0 forks source link

Setting up RPi #1

Open xyzarivera opened 8 months ago

xyzarivera commented 8 months ago

Overview

This ticket is my progress tracker for setting up the raspberry pi which will host the app I'm creating.

Goals

xyzarivera commented 8 months ago

Advanced Options in Raspberry Pi Imager

hostname: custom username: preferrably, the same username as main machine (mac machine)

Enable SSH - Allow public key authentication only

Accessing the RPi via the main machine

ssh [username]@[hostname].local

Error: Permission denied

[username]@[hostname].local: Permission denied (publickey).

Public key used during setup did not match from default public key based on ~/.ssh/config in the main machine Apparently, I have 2 ssh keys, default and key_2. The RPi Imager, pre-filled the input field with key_2.pub.

~/.ssh/config

Host *
   AddKeysToAgent yes
   UseKeychain yes
   IdentityFile ~/.ssh/default

Host github.com
   Hostname ssh.github.com
   Port 443

Fix # 1

Add key_2 to the main machine's ~/.ssh/config as the assigned ssh key for the RPi

Host <hostname>.local
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/key_2

Fix # 2

Update the RPi's ~/.ssh/authorized_keys to have the default ssh key, using this cli command in the main machine.

ssh-copy-id -i ~/.ssh/default.pub [username]@[hostname].local

Shutting down the RPi

Raspbian is a Debian-based OS. Checked for commands under this distro.

shutdown -h now
xyzarivera commented 7 months ago

Connecting to wireless networks

It would be nice that I wouldn't need to use a monitor every time I will add a wifi network to connect to.

wpa_supplicant.conf doesn't work anymore

As of writing, Raspberry PI documentation on connecting to wireless networks says that creating a wpa_supplicant.conf in the SD card's root directory will not work from Raspberry Pi OS Bookworm onwards.

I tried several attempts already to resolve this but it seems most forum posts are outdated.

raspi-config is an option

This will still be an option but it would still need a monitor.

using nmcli

NetworkManager (nmcli) allow network configuration in the cli. Feels painless since I can initially connect to the Pi via my phone's hotspot to add a new network, then connect to that network after set up.

connecting to a hidden network

nmcli c add type <network type> con-name <connection name> ifname <inteface> ssid <ssid>
nmcli con modify <connection name> wifi-sec.key-mgmt <key-mgmt>
nmcli con modify <connection name>wifi-sec.psk <password>
nmcli con up <connection name>

nmcli con delete <connection name>

nmcli dev wifi connect z password ptclptcl hidden yes
nmcli c add type wifi con-name home-wifi ifname wlp61s0 ssid z
nmcli con modify home-wifi wifi-sec.key-mgmt wpa-psk 
nmcli con modify home-wifi wifi-sec.psk ptclptcl
nmcli con up home-wifi

nmcli con delete home-wifi

nmcli dev wifi connect <ssid> password <password> hidden yes

Note: WPA2/WPA-3 Personal is under wpa-psk key management

common commands

nmcli c delete SSID

nmcli d wifi - list all wifi available

nmcli d wifi connect SSID password “ssidpassword” - quotation marks required

nmcli d - list connected networks