The Hotel Hero

Notes by a Sysadmin

Cluster | Philosophy | Stack

New Pi Setup

April 9, 2021 | Stack

Install OS

Install the Pi Imager tool from Raspberry Pi's homepage: 

Insert your SD-card in your PC, and select OS (choose an 64-bit version if you are running Rpi 3 < ) and SD-card and continue..

Headless setup (Only for Raspian OS)

Now, most of us don't have a micro-HDMI -> HDMI lying around (RPi4), and in general i prefer headless operations when working with servers. So, unless you plan to specific using your RPi4 for desptop work, make the following changes befor putting the SD-card in the Pi.

Find the "system-boot"/"boot" and make a blank file called "ssh" here.

Setup Wireless (If you need that)

Find the "system-boot" and open the file "network-config" and unmark the following lines:

    dhcp4: true
    optional: true
        password: "S3kr1t"

Boot the Pi

Now boot the Pi with the SD-card and locate the IP address. I prefer nmap:

nmap (or what ever the netmask is on you network)

So, now you have your IP.

SSH into the pi (user:ubuntu, pass: ubuntu) to make some changes and setup Docker Swarm.

General changes 

Default you get prompted to change password on first boot, do that.

secondly you want to make key exchange with all nodes (Swarm related) and you might want to do the same on the PC.

PC -> Pi 
Pi (master node) -> Pi (agents/slaves/workers)

Follow the instructions here:


Change these two files to setup hostname:

edit the following /etc/hosts to include the hostname ( pi1): localhost pi1
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

and edit /etc/hostname and change it to "pi1" (or what ever name you will give it).

Depending on your router, DNS can in some circumstances be a bit tricky on Ubuntu ARM. Follow this instruction if you experience troubles: 

Static IP (Ubuntu Pi)

In Ubuntu Pi use Netplan to set the IP, navigate to /etc/netplan:

ls /etc/netplan

And edit the file in there to something similar to this (make sure the ip-addresses ar correct, and network interface "eth0" should be the correct one):

    renderer: networkd
            dhcp4: no    
            optional: true
            addresses: []
              addresses: [,]
    version: 2

and apply the changes (make sure to double check every thing, you can end up with a Pi that is not accessible on the network interfaces if you fuck it up, like I did by mistake the other day.)

So, test the configuration and attempt to login from another terminal session:

sudo netplan try

Static IP (Raspian)

On Raspian OS edit the file /etc/dhcpcd.conf:

sudo nano /etc/dhcpcd.conf

and change it to something similar:

interface eth0
static ip_address=
static routers=
static domain_name_servers=


Basically the above steps, are what I use when setting up Pi's no matter what I am planing for as use case. In this way you get a secure access, a static IP and a hostname.

Things to consider as addition to the above is setting, could be firewall setup or VNC viewer if you have choosen a GUI OS.


I'm a Sysadmin, network manager and cyber security entusiast. The main purpose of this public "notebook" is for referencing repetitive tasks, but it might as well come in handy to others. Windows can not be supported! But all other OS compliant with the POSIX-standard can (with minor adjustments) apply the configs on the site. It is Mac OSX, RHEL and all the Fedora based distros and Debian based (several 100's of OS's), all the BSD distros, Solaris, AIX and HP-UX.