Skip to content

Instantly share code, notes, and snippets.

@davidbarkhuizen
Last active February 4, 2021 13:13
Show Gist options
  • Select an option

  • Save davidbarkhuizen/86a476fe698779760dfff4287d65ab72 to your computer and use it in GitHub Desktop.

Select an option

Save davidbarkhuizen/86a476fe698779760dfff4287d65ab72 to your computer and use it in GitHub Desktop.
Raspberry Pi 4 - Ubuntu Platform

Raspberry Pi | Ubuntu - Platform

ubuntu 20-10 running on the RPi4b

https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi

Setup

Prior to First Boot

Provide Seed Configure Data for Wifi Connection

edit network-config file in system-boot partition on SD card, e.g.

wifis:
  wlan0:
  dhcp4: true
  optional: true
  access-points:
    "home network":
      password: "123456789"

Power up the pi, wait until all green LED activity ceases, then reboot, the pi should now auto-connect to the wifi network using seed credentials supplied going forward.

Configure New User, Delete Default System User Account

The default login username is "ubuntu", password is "ubuntu". You will be asked to change the password on first login - this is good, but better still will be to create a new user, then delete the default user (ubuntu).

# create new user xxx $ sudo adduser xxx

# add user xxx to sudo group, allowing them to execute sudo and launch as root
$ sudo usermod -aG sudo xxx

logout default user, login with new user

# edit /etc/passwd and change default shell for user xxx from /bin/sh (default shell) to bin/bash (bash)

# delete default user ubuntu, with their home directory
$ sudo userdel -r ubuntu

SSH

Install & Configure SSH Server (sshd - SSH Daemon)

Some images come with ssh-daemon installed, configured and running by default, otherwise:

# install sshd os package
$ sudo apt install openssh-server

# confirm that sshd is installed and running:
$ sudo systemctl status ssh

sample output:

● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-02-04 11:27:09 SAST; 3h 40min ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 879 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 900 (sshd)
      Tasks: 1 (limit: 4135)
     CGroup: /system.slice/ssh.service
             └─900 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

Feb 04 11:27:09 djinn systemd[1]: Starting OpenBSD Secure Shell server...
Feb 04 11:27:09 djinn systemd[1]: Started OpenBSD Secure Shell server.
Feb 04 11:27:09 djinn sshd[900]: Server listening on 0.0.0.0 port 22.
Feb 04 11:27:09 djinn sshd[900]: Server listening on :: port 22.

# open a hole in the firewall for SSH port (22)
$ sudo ufw allow ssh

Test Remote SSH Connection

From an alternative machine on the same network:

# connect to a host with IP address a.b.c.d as user xxx
$ ssh a.b.c.d -l xxx
or:
$ ssh [email protected]

# update the package manager with the information about the latest packages
$ sudo apt update

# upgrade all packages on the machine
$ sudo apt upgrade

Manage the WIFI Connection from the Command Line

# list network interfaces
$ ifconfig -a

# bring wifi interface xxx up
$ sudo ifconfig xxx up

# take wifi interface xxx up
$ sudo ifconfig xxx down

# generate WPA2 PSK file for SSID network_ssid and pre-shared-key network_key
# and store in file the_network.conf in file location /etc/wpa_supplicant/
$ wpa_passphrase network_ssid network_key > /etc/wpa_supplicant/the_network.conf
$ sudo cp wpa_supplicant.conf /etc/wpa_supplicant/the_network.conf

# connect to WPA2 PSK-protected network on interface xxx
# using connection config file /etc/wpa_supplicant/the_network.conf
$ sudo wpa_supplicant -ixxx -c/etc/wpa_supplicant/the_network.conf -Dwext
# establish connnection and run as background process, echoing to standard out
$ sudo -B ...

# launch DHCP client to obtain IP from DHCP server on network interface xxx
$ sudo dhclient xxx

# all in one
$ sudo wpa_supplicant ... & sudo dhclient ...

====

# scan for list of networks
$ nmcli d wifi list

sudo apt-get install openssh-server (pre-installed)

2nd Wifi

Monitor Mode with External USB Wifi in Ubuntu

Realtek RTL8192EU Chipset

from the RealTek website:

The Realtek RTL8192EU-VL-CG is an 802.11bgn 2.4G single-chip that integrates Wireless LAN (WLAN) and a network USB interface (USB 1.0/1.1/2.0 compatible) controller. It combines a WLAN MAC, a 2T2R capable WLAN baseband, and WLAN RF in a single chip. The RTL8192EU-VL-CG provides a complete solution for a high-throughput performance and low power consumption integrated wireless LAN device.

MediaTek MT7601U Chipset

from the MediaTek website:

MediaTek MT7601U is a highly integrated Wi-Fi single chip that's fully compliant with 802.11b/g/n standards (150Mbit/s PHY), offering feature-rich, reliable and cost-effective wireless connectivity from an extended distance.

TP-LINK 300Mbps Wireless N Mini USB Adapter (TL-WN823N)

Driver from Christian Bremvåg - [email protected]

Linux driver for Realtek RTL8192EU based on official's TP Link TL - WN823N V3 Beta v5.2.19.1 from 2018-05-08 Supports monitor mode and frame injection for penetration testing abilities.

https://github.com/Mange/rtl8192eu-linux-driver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment