The Raspberry Pi computer is deployed in VLAN 100 of the network as a secure reverse web proxy and ssh proxy server to prevent direct access to the infrastructure resources and protect these applications. This section will guide you through the steps to install the Raspberry Pi OS onto your Raspberry Pi along with the configuration instructions to deploy this system in the network. The guide is intended to be used to install on a Raspberry Pi 3 Model B. Any later model should also work.
The Raspberry Pi OS comes as a disk image that needs to be flashed onto an SD card using a special utility. On Chromebooks, we will use the Chromebook Recovery Utility extension to install the Raspberry Pi OS onto your SD card.
The Raspberry Pi doesn't come with a hard drive. Instead, the system has a microSD card reader and requires the OS to be installed on a removable media. This section will guide you through the process of downloading and installing the Raspberry Pi OS onto a microSD card for your Raspberry Pi.
With the Raspberry Pi OS installed on the microSD card, you can now insert the card into the Raspberry Pi and boot up your system. You will need to connect a keyboard and a screen to complete the initial setup of your system and get it ready to be installed. During the first boot process, you'll be prompted to create a username and password for accessing the system. Keep a record of these as you will need them to perform regular maintenance on the system.
The first task to accomplish on your new Raspberry Pi system is to expand the filesystem to use your entire microSD card. The OS comes preset with a small size and it doesn't take into account different microSD cards, to get around this, we'll use a function built into the configuration tool to maximize the available space.
sudo raspi-config
WARNING - This paragraph still needs to have instructions on how to find the interface name and this needs to be included in the configuration.
The Raspberry Pi OS is configured to receive an IP address as a DHCP client by default. While this provides easy access to the network, it isn't well suited to provide the best solution for our SSH proxy and reverse web proxy service. This step guides you through setting up a static IP address, as shown in the network diagram.
sudo vi /etc/dhcpcd.conf
interface enxsnp08
static_routers=10.10.100.1
static domain_name_servers=8.8.8.8,8.8.4.4
static ip_address=10.10.100.2/24
:wq
and hitting the enter key.sudo systemctl restart dhcpcd.service
. This will restard the networking service on your Raspberry Pi and load the new IP address configuration.Secure Shell is the key to being able to manage your Raspberry Pi remotely and to setting up the SSH Proxy server so we can access the rest of our infrastructure from the internet.
sudo raspi-config
Enabling Key-Based authentication ensures that your Raspberry Pi is only accessible from a trusted device and is a crucial portion of getting the SSH Proxy to work properly.
ssh-copy-id eric@10.10.100.1
Now that public key authentication has been configured, the next step is to completely disable password authentication to reduce the possibility of the SSH server being vulnerable to brute force password attacks.
sudo vi /etc/ssh/sshd_config
PasswordAuthentication no
:wq
and hitting the enter key.sudo systemctl restart ssh
With ssh set up on your raspberry pi, this next section outlines what you need to do on your laptop (or other remote device) that you want to use to manage the internal systems.
vi .ssh/config
to modify the ssh configuration.Host rpi
Hostname home.desgroseilliers.ca
User eric
IdentityFile ~/.ssh/id_ed25519
Host home
Hostname 10.10.10.51
ProxyJump rpi
User eric
IdentityFile ~/.ssh/id_ed25519
Although there are multiple approaches to getting docker installed on Raspberry Pi OS, I choose to follow the official docker approach because this gives me the latest version of docker that aligns with the documentation. The official instructions can be found here. I've shortenned the steps below to make it a little faster.
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world
This section outlines the steps to install and configure unattended-upgrades on your raspberry pi to keep the system updated.
sudo apt-get update
sudo apt-get install unattended-upgrades
Modify the file /etc/apt/apt.conf.d/50unattended-upgrades
. Scroll down to the Origins-Pattern section and uncomment the updates and proposed-updates lines. The config file should look like this:
Unattended-Upgrade::Origins-Pattern {
// Codename based matching:
// This will follow the migration of a release through different
// archives (e.g. from testing to stable and later oldstable).
// Software will be the latest available for the named release,
// but the Debian release itself will not be automatically upgraded.
"origin=Debian,codename=${distro_codename}-updates";
"origin=Debian,codename=${distro_codename}-proposed-updates";
"origin=Debian,codename=${distro_codename},label=Debian";
"origin=Debian,codename=${distro_codename},label=Debian-Security";
"origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
// Archive or Suite based matching:
// Note that this will silently match a different release after
// migration to the specified archive (e.g. testing becomes the
// new stable).
// "o=Debian,a=stable";
// "o=Debian,a=stable-updates";
// "o=Debian,a=proposed-updates";
// "o=Debian Backports,a=${distro_codename}-backports,l=Debian Backports";
};
sudo dpkg-reconfigure --priority=low unattended-upgrades