Yesterday’s post included a reminder that when setting up a new Pi it is important to change the default password of the pi
user. In most distributed computing environments is it also best practice to create individual user accounts to manage access to the various nodes on the network.
My preference is to have a user that can access each node without needing to type a password. This is accomplished with our favorite remote access tool SSH.
I followed the steps outlined below with reference to this guideline from the RPi Foundation.
As the pi
user I can set up a new user for myself.
sudo adduser michael
sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi michael
michael
then has permission to act as a sudoer, so I finished the rest of my work on the node logged in as this user using su
(swtich user).
sudo su - michael
raspi-config
as new user
sudo raspi-config
raspi-config
brings up an interactive menu. Here I set the hostname and timezone.
From my main computer I use ssh-copy-id
which will install my public key onto the node.
ssh-copy-id michael@node1
The resulting output:
Number of key(s) added: 1
Following this process on each node makes it easy to use my main computer as a workspace and perform tasks. Now that I can connect to each node individually, my next goal is to install Ansible and dive into what sort of automations I can tinker with.
Additionally, because I know Ansible only needs to be installed on one node and its agentless operation requires SSH access, I have also generated an SSH key on node1
and copied the ID to all the other nodes so that Ansible will be able to perform actions as michael
.
The cluster is built and looking good! With a bare metal set up, the next step is to get the operating system provisioned and loaded onto the SD cards. After that, it’s time to power up the Pis and get them established on my local network.
For this installation, I’ve gone with the latest available Raspberry Pi OS from the RPi Foundation. It’s the default, and if anything is true it’s that the default mode is the easiest to set up and what’s easy is likely what’s going to keep happening. My goal here is to set up a cluster that enables the deployment of containers. Choosing the right OS for the job is simple in this case because Raspberry Pi OS is built for these machines.
Using the Raspberry Pi Imager it was easy to get the SD cards flashed and ready to go.
The only additional step I took here was enabling SSH on each Pi by mounting the SD card and executing the following command (from Mac OS)
touch /Volumes/boot/ssh
If you don’t already know what SSH is, there are plenty of YouTube videos to help you out. It’s a common tool used to connect to computers, and the above command simply creates a file called ssh
that the OS will look for to automatically enable SSH when the Pi nodes boot for the first time.
I used
nmap
to figure out the IP addresses of the individual nodes.
nmap -sT -p 22 192.168.1.0/24
The arguments here specify TCP connections using port 22 within the given IP range.
From the report nmap provided I determined each node’s dynamically-assigned IP address. I then assigned each node a static IP address so that they will always be accessible from predictable and known locations. I’m not very creative; my naming scheme was simply node*
so my hostnames inventory looks like this:
node1
node2
node3
node4
node5
node6
I can sometimes take it for granted that installing a fresh OS with SSH enabled means it’s an unsecured Linux box running on my network and that it’s on me to change the default password, so I’ll note here for posterity that setting up a cluster with unsecured nodes is NOT good. The first thing you should do is change the default credentials.
The default user and password for Raspberry Pi OS is pi
and raspberry
.
I’ve hosted various blogs across different platforms. Way back in the day I played around with Geocities and Xanga. Then there were the blessed days of Posterous. Most recently I hosted a blog using Ghost. In this latest foray, I’ll be running one attached to my Github profile using Github:Pages with focus on more technical subjects.
I want to use this blog to document a new sandbox project to explore cluster computing concepts.
A computer cluster is a set of computers working together and viewed as a single system. The individual computers that make up a cluster are called nodes.
Here’s what I’ve purchased so far:
Qty | Item | Store | Cost |
---|---|---|---|
1 | GeeekPi 6-Layers Raspberry Pi Cluster Case (Clear) | Amazon | $20 |
6 | Raspberry Pi 4 Model B/4GB | PiShop.us | $55/node |
6 | 32 GB SD cards | various | < $10/card |
1 | TP-Link Litewave 8 Port Gigabit Ethernet Switch | Amazon | $16 |
1 | CAT 6 Ethernet Cable - 10 Pack (1.5 ft) | Amazon | $13 |
2 | AUKEY USB Charger 4 Ports | Amazon | $13 |
2 | USB Type C Cable, Anker [3-Pack, 6 ft] | Amazon | $17 |
My name is Michael Lamb. I’m a software engineer currently living in Jackson, Mississippi, and I like to write so that’s why this blog exists.
If you want to get to know me better here are a few things about my life:
I deployed this blog for free using Github Pages. The source code for this blog is available from my GitHub profile and the repository README has more details about the technologies used to build michaellamb.dev. There is a link to the repository in the Public Repository section of the navbar.
I plan to use this blog to write technical content related to work I do on my home lab cluster. As a software engineer my primary skills involve reading and writing code and I am always working in a local development environment for personal projects.
Here are some things I’d like to focus on:
If you have any sponsorship inquiries please email me at [email protected]. You can sponsor specific projects you want to see me work on!