Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

Tuesday, November 24, 2026

Okta as Code, Part 1

Setting Up Terraform on Debian

Managing Okta by clicking through the Admin Console works, until you need a second environment or want to know who changed what. In this post I put an Okta org under Terraform on a minimal Debian 13 server, step by step. Every command is followed by a short explanation, and every code box has a Copy button.

Placeholders: my Okta org is integrator-4574553, and I use that name in file names. Replace it with your own org name everywhere it appears.

What you need first

  • A Debian 13 machine (I used a minimal install over SSH) and an Okta org with admin access.
  • An OAuth service app with a private key, not an API token. A token has the full rights of the admin who created it and expires after 30 days unused. A service app only gets the scopes and role you give it.

Step 1: Install Terraform

Minimal Debian has no sudo. If you get sudo: command not found, run su -, then apt-get install -y sudo and usermod -aG sudo YOURUSER, then log out and back in.

First, install the tools needed to add HashiCorp's package repository:

sudo apt-get update && sudo apt-get install -y gnupg curl lsb-release

apt-get update refreshes the list of available packages. && runs the second command only if the first succeeds. The install adds three tools:

  • gnupg checks cryptographic signatures
  • curl downloads files
  • lsb-release reports your Debian codename (for example trixie)

Download HashiCorp's signing key:

wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

This downloads the public key (wget -O- prints it instead of saving it), pipes it (|) into gpg --dearmor, which converts it to the binary format apt expects, and saves it in the keyrings folder. apt uses it to verify that packages really come from HashiCorp.

Add the HashiCorp repository:

echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

This writes one line into a new apt source file, telling Debian where HashiCorp's packages live and which key to trust. $(lsb_release -cs) fills in your Debian codename, and tee with sudo lets you write into a protected folder. If you get a 404 later, replace the codename with bookworm.

Install Terraform and check the version:

sudo apt-get update && sudo apt-get install -y terraform
terraform -version

The first line refreshes the package list (now including HashiCorp) and installs Terraform. The second prints the version, which proves it works. This guide needs 1.10 or higher.

terraform -version output

Step 2: Create the service app in Okta

In the Admin Console, go to Applications > Applications > Create App Integration. Choose API Services, name it Terraform, and keep the default Okta-generated client ID.

Creating the API Services app in Okta
Terraform app created in Okta

On the General tab, under Client Credentials, choose Public key / Private key.

Now add a public key: click Add > Generate new key and choose the key size (I used 4096-bit).

Adding a public key to the Okta app

The private key is shown only once. Select the PEM tab (not JSON) and click Copy to clipboard. Keep this dialog open while you save the key on your server (next step).

The generated key in PEM and JSON formats

Next, on the Okta API Scopes tab, grant the scopes you need, for example okta.groups.manage. A typical set:

okta.groups.manage
okta.apps.manage
okta.policies.manage
okta.authorizationServers.manage
okta.users.manage
okta.idps.manage
okta.trustedOrigins.manage
okta.schemas.manage
okta.networkZones.manage
okta.brands.manage
Granting API scopes

Scopes alone are not enough: the app also needs an admin role. On Admin roles, assign Super Administrator to start with, and narrow it to a custom role later.

Admin roles tab
Super Administrator assigned

Finally, copy the Client ID from the top of the General tab. It is not a secret.

Step 3: Store the credentials on the server

Back in the terminal. Create a private folder for secrets in your home directory:

mkdir -p ~/.okta && chmod 700 ~/.okta

-p means no error if it already exists. chmod 700 makes the folder accessible only to you.

Create the key file, paste the PEM you copied, press Ctrl+O then Enter to save, and Ctrl+X to exit:

nano ~/.okta/terraform-okta-integrator-4574553.pem

Make the key readable and writable by you only, then check the first line without showing the key:

chmod 600 ~/.okta/terraform-okta-integrator-4574553.pem
head -1 ~/.okta/terraform-okta-integrator-4574553.pem

The second command should print -----BEGIN PRIVATE KEY-----.

Create the credentials file:

nano ~/.okta/okta-integrator-4574553.env

Paste this, replacing the Client ID and KID with your real values from Okta (not the placeholders):

export OKTA_ORG_NAME="integrator-4574553"        # yourorg.okta.com -> "yourorg"
export OKTA_BASE_URL="okta.com"                  # or oktapreview.com / okta-emea.com
export OKTA_API_CLIENT_ID="YOUR_CLIENT_ID"
export OKTA_API_PRIVATE_KEY_ID="YOUR_KID"
export OKTA_API_PRIVATE_KEY="$(cat ~/.okta/terraform-okta-integrator-4574553.pem)"
export OKTA_API_SCOPES="okta.groups.manage,okta.apps.manage,okta.policies.manage,okta.authorizationServers.manage,okta.users.manage"
The credentials file

What each line does:

  • OKTA_ORG_NAME: the first part of your Okta URL
  • OKTA_BASE_URL: the domain, usually okta.com
  • OKTA_API_CLIENT_ID: which app is logging in
  • OKTA_API_PRIVATE_KEY_ID: the KID of the registered key
  • OKTA_API_PRIVATE_KEY: the contents of the PEM, read in by $(cat ...)
  • OKTA_API_SCOPES: the permissions requested

Restrict the file to you only:

chmod 600 ~/.okta/okta-integrator-4574553.env

Load the variables into your current terminal:

source ~/.okta/okta-integrator-4574553.env

Run this in every new terminal, and again after editing the file, because a terminal keeps the old values until you reload.

Optional: load the credentials automatically

To avoid typing source each time, add it to your shell startup file:

nano ~/.bashrc

Add this line at the very bottom, save, then load it in the current terminal:

source ~/.okta/okta-integrator-4574553.env
source ~/.bashrc
Trade-off: your private key is then present in every terminal session. That is fine on a personal home server, but on a shared machine, or once you manage more than one Okta org, load the right file by hand instead.

Step 4: Set up Git and the project folders

Install Git, which tracks changes to your files:

sudo apt-get install -y git

Tell Git who you are (used in commit history) and name the default branch main:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main

Create the project folder, with one subfolder per Okta org. That keeps each org's code and state separate:

mkdir -p ~/okta-terraform/envs/okta-integrator-4574553

Move into the project root and turn it into a Git repository:

cd ~/okta-terraform
git init

Create the file that tells Git what never to track:

nano .gitignore
.terraform/
*.tfstate
*.tfstate.*
*.tfvars
*.pem
*.env
key.json
crash.log
Why this matters: Terraform state files can contain secrets, and keys must never reach GitHub. Keep your .pem and .env files in ~/.okta, outside the repo, and make any GitHub repo private. Do not ignore .terraform.lock.hcl; that one should be committed.

Save the ignore file as the first commit:

git add .gitignore
git commit -m "Add .gitignore"

git add stages the file and git commit records it in history with a message.

Step 5: Write the Terraform files

Move into the folder where Terraform runs. All terraform commands go here:

cd ~/okta-terraform/envs/okta-integrator-4574553

versions.tf pins the versions. It needs Terraform 1.10 or newer and the Okta provider from the 5.x series. With no backend block, state stays in a local file.

nano versions.tf
terraform {
  required_version = ">= 1.10"

  required_providers {
    okta = {
      source  = "okta/okta"
      version = "~> 5.0"
    }
  }
}

provider.tf sets rate-limit and retry behaviour. It uses at most 50% of Okta's API rate limit and waits and retries when limited. There are no credentials here, because they come from the OKTA_* variables.

nano provider.tf
provider "okta" {
  max_api_capacity = 50
  backoff          = true
  min_wait_seconds = 5
  max_wait_seconds = 60
  max_retries      = 5
}

main.tf holds the actual resources, a small first test:

nano main.tf
data "okta_group" "everyone" {
  name = "Everyone"
}

resource "okta_group" "engineering" {
  name        = "Engineering"
  description = "Managed by Terraform"
}

resource "okta_group_rule" "engineering" {
  name              = "Engineering by department"
  status            = "ACTIVE"
  group_assignments = [okta_group.engineering.id]
  expression_type   = "urn:okta:expression:1.0"
  expression_value  = "user.department==\"Engineering\""
}
  • data "okta_group" only reads the built-in Everyone group and changes nothing. Built-in objects cannot be created or deleted, so you reference them with a data source.
  • resource "okta_group" creates a group named Engineering.
  • resource "okta_group_rule" automatically adds users whose department equals Engineering.

Step 6: Run Terraform

Download the Okta provider plugin and create .terraform.lock.hcl, which records the exact versions. This step needs no credentials:

terraform init

Check the files for syntax errors without contacting Okta:

terraform validate

Show what would be created, changed or deleted, without changing anything. This is the first step that logs in to Okta, so credential problems appear here:

source ~/.okta/okta-integrator-4574553.env
terraform plan

A good result ends with Plan: 2 to add, 0 to change, 0 to destroy. Then apply it:

terraform apply

Terraform shows the plan again and, after you type yes, creates the group and rule. Check them in the Admin Console under Directory > Groups.

Commit your work

Go to the project root and check what Git sees. No .pem, .env or .tfstate file should appear in the list:

cd ~/okta-terraform
git status

Add the files by name (safer than git add .) and commit:

git add envs/okta-integrator-4574553/*.tf envs/okta-integrator-4574553/.terraform.lock.hcl
git commit -m "Add Okta Terraform config"


Sunday, November 22, 2026

Debian 13 on an old Intel NUC

Debian 13 on an Intel NUC: a step-by-step installer guide

This walkthrough follows the installation for a dedicated, headless n8n server on an Intel NUC. The images are clean recreations of photographed installer screens, so check the live installer before making a final choice. Screen 21 reflects the final software selections reported after its source photo was taken.

Drive warning: The whole-disk steps erase the selected drive. In this example the 120 GB internal Kingston is /dev/sda and the 30.8 GB SanDisk installer USB is /dev/sdb. Verify model and capacity on your own screen because device names can change.

Boot and basic settings

1. Open the boot menu

At the Intel NUC splash, press F10.

Debian installer screen 01: Open the boot menu
Screen 01: Open the boot menu

2. Boot the installer USB

Select the USB: SanDisk entry, not the internal Kingston.

Debian installer screen 02: Boot the installer USB
Screen 02: Boot the installer USB

3. Start Debian

Select Graphical install. The photo shows Debian 13 in BIOS mode.

Debian installer screen 03: Start Debian
Screen 03: Start Debian

4. Choose a language

English is selected in the photo. Choose the language you want for the installed system.

Debian installer screen 04: Choose a language
Screen 04: Choose a language

5. Choose your location

Select the country where the NUC will be used. This affects time zone and the initial mirror list; the photo highlights United States, but United Kingdom is also visible.

Debian installer screen 05: Choose your location
Screen 05: Choose your location

6. Choose your keyboard

Match the physical keyboard. The photo highlights American English; choose British English for a UK keyboard.

Debian installer screen 06: Choose your keyboard
Screen 06: Choose your keyboard

Network and account

7. Pick the network adapter

Use enp0s25 for a connected Ethernet cable, or wlp2s0 for Wi-Fi. A wired connection is usually simpler for a server.

Debian installer screen 07: Pick the network adapter
Screen 07: Pick the network adapter

8. Wait for DHCP

The installer requests an address automatically.

Debian installer screen 08: Wait for DHCP
Screen 08: Wait for DHCP

9. If DHCP fails

Check the cable/router or Wi-Fi connection, then retry. If you must continue offline, the installer may have to skip the network mirror; connect the machine and update packages after installation.

Debian installer screen 09: If DHCP fails
Screen 09: If DHCP fails

10. Set a hostname

debian works; a useful name such as n8n-nuc makes the machine easier to identify.

Debian installer screen 10: Set a hostname
Screen 10: Set a hostname

11. Set the domain name

Leave this blank if you do not run a local domain. The photo shows mynet, which you need only if it is actually your network's domain.

Debian installer screen 11: Set the domain name
Screen 11: Set the domain name

12. Set administrator access

Leaving the root password blank locks direct root password access and gives the first user sudo access. This is a good choice for a personal server.

Debian installer screen 12: Set administrator access
Screen 12: Set administrator access

13. Create your user

Enter your name, then follow the next prompts to set a login name and a strong password.

Debian installer screen 13: Create your user
Screen 13: Create your user

Partition the internal drive

14. Choose a partitioning method

For a dedicated NUC that may reboot unattended, choose Guided - use entire disk and set up LVM. Choose encrypted LVM if you want a passphrase at startup. The later photos show that the path captured here uses plain, unencrypted LVM. The highlighted “largest continuous free space” option in this photo is a different path.

Debian installer screen 14: Choose a partitioning method
Screen 14: Choose a partitioning method

15. Choose the disk carefully

Select the 120.0 GB ATA KINGSTON internal drive. The 30.8 GB SanDisk Cruzer Blade is the installer USB. Do not confirm until the model and capacity match the drive you intend to erase.

Debian installer screen 15: Choose the disk carefully
Screen 15: Choose the disk carefully

16. Choose the layout

All files in one partition is a practical simple layout for this 120 GB n8n machine.

Debian installer screen 16: Choose the layout
Screen 16: Choose the layout

17. First write warning

Confirm only if the listed disk is the internal Kingston and you have a backup. This writes partition changes so LVM can be configured.

Debian installer screen 17: First write warning
Screen 17: First write warning

18. Choose LVM space

The installer offers 119.0 GB. Keeping the default uses almost all available space for the guided layout.

Debian installer screen 18: Choose LVM space
Screen 18: Choose LVM space

19. Final format warning

Review the listed sda partitions, root filesystem, and swap. Yes formats them and erases existing data on that disk. If anything is wrong, choose No and go back.

Debian installer screen 19: Final format warning
Screen 19: Final format warning

20. Select the Debian mirror

Choose deb.debian.org if the machine has working internet. If the earlier DHCP failure remains unresolved, fix networking first or use the installer's offline path if offered.

Debian installer screen 20: Select the Debian mirror
Screen 20: Select the Debian mirror

Finish Debian

21. Choose software

For this headless n8n server, you reported leaving SSH server and standard system utilities selected, while clearing web server and all desktop environment options. The original photo was taken before these final changes; the recreated screen shows the final selection you described.

Debian installer screen 21: Choose software
Screen 21: Choose software

22. Install GRUB

Choose Yes to install the boot loader to the primary drive, provided this is the intended single-OS setup.

Debian installer screen 22: Install GRUB
Screen 22: Install GRUB

23. Choose the GRUB device carefully

Select the internal Kingston drive shown here as /dev/sda, not the SanDisk Cruzer Blade installer USB shown as /dev/sdb. Verify the drive names on your own screen.

Debian installer screen 23: Choose the GRUB device carefully
Screen 23: Choose the GRUB device carefully

24. Complete and reboot

Remove the installation USB and choose Continue. The NUC should boot from the internal drive into Debian.

Debian installer screen 24: Complete and reboot
Screen 24: Complete and reboot

After the first boot

Sign in, confirm that the network works, then update Debian with sudo apt update && sudo apt upgrade. Next, follow the current Docker Engine instructions for Debian and n8n's Docker Compose instructions. Keep n8n data in a persistent volume and back it up. If you need access from the internet, put it behind HTTPS and a reverse proxy.

References: Debian installation guide · Docker Engine on Debian · n8n with Docker Compose

Bootable Debian USB on Linux

How to Create a Bootable Debian USB on Linux – A Practical Guide

I recently decided to give an older Intel NUC a new lease of life by installing Debian on it.

Rather than using Windows or relying on a collection of third-party applications, I wanted to prepare everything from my existing Linux machine.

In this guide, we'll use the terminal to download and verify the Debian ISO, identify our USB drive, and use GNOME Disks to create the bootable USB.

The commands were tested on Xubuntu, but the overall process is applicable to other Linux distributions. Package installation commands may vary.

1. Install the required tools

First, update your package information and install wget:

sudo apt update
sudo apt install wget

We'll also use GNOME Disks to write the ISO image to the USB drive:

sudo apt install gnome-disk-utility

Launch GNOME Disks with:

gnome-disks

2. Download Debian

For this installation, I chose Debian Netinst (amd64).

The Netinst image is relatively small. It contains the installer and retrieves additional packages over the internet during installation.

Navigate to your Downloads directory:

cd ~/Downloads

Option 1: Download a specific Debian version

Download the Debian ISO (This is version dependent):

wget -O debian.iso https://cloudfront.debian.net/debian-cd/current/amd64/iso-cd/debian-13.8.0-amd64-netinst.iso

Note: This example uses Debian 13.8. Replace the version number in the URL when a newer release becomes available.

Option 2: Automatically download the current version

Alternatively, use the following commands to download the current Netinst ISO without manually specifying the version number:

wget -r -l1 -nd -A 'debian-[0-9]*-amd64-netinst.iso' --no-parent https://cloudfront.debian.net/debian-cd/current/amd64/iso-cd/

mv debian-*-amd64-netinst.iso debian.iso

The first command downloads the versioned ISO from Debian's current directory. The second renames it to debian.iso, so you can follow the remaining instructions without changing any filenames.

Both methods leave you with a file named debian.iso in your Downloads directory.

Why Netinst? You don't need a large installation image containing every package. The network installer retrieves the required packages during installation, provided the target computer has an internet connection.

For the latest Debian release, visit the official download page:

https://www.debian.org/distrib/

3. Verify the downloaded ISO

Before writing anything to the USB drive, check that the download completed successfully.

file debian.iso
ls -lh debian.iso

My output confirmed that the file was recognised as a bootable ISO 9660 image:

debian.iso: ISO 9660 CD-ROM filesystem data (DOS/MBR boot sector) (bootable)

The downloaded file was approximately 758 MB in my test.

For additional assurance, you can verify its SHA256 checksum against Debian's official checksum file.

4. Identify your USB drive

Connect your USB stick. Before writing the image, identify the correct device. This is important because the process will erase the selected USB drive.

lsblk -o NAME,SIZE,MODEL,TRAN,MOUNTPOINTS

My USB drive appeared as:

NAME   SIZE  MODEL         TRAN
sda   111.8G KINGSTON      sata
sdb    28.7G Cruzer Blade  usb

In my case:

  • /dev/sda was the internal Kingston SSD.
  • /dev/sdb was the 28.7 GB SanDisk Cruzer Blade USB stick.

Important: Your device names may be different. Never assume your USB drive is /dev/sdb. Identify it using its model, size and connection type.

5. Write Debian to the USB drive

Launch GNOME Disks:

gnome-disks

In the application:

  1. Select your USB drive from the left-hand panel.


  2. Open the three-dot menu in the top-right corner.
  3. Select Restore Disk Image…

  4. Choose the downloaded debian.iso file from your Downloads folder.
  5. Click Start Restoring…

  6. Confirm the operation and authenticate if requested.


  7. Wait for the writing process to finish.
Warning: This operation completely erases the selected USB drive. Double-check that you've selected the USB stick and not your internal SSD.

Once the operation completes, safely eject the USB drive.

6. Ready to install Debian!

That's it. We now have a bootable Debian installation USB.

The next step is to connect the USB stick to the target computer, enter its boot menu and start the Debian installer.

From there, you can choose your installation options and configure the machine as a desktop, lightweight server or home lab.

Final thoughts

I like keeping things simple. There was no need for a complicated workflow or a heavyweight application.

A few terminal commands, a Debian ISO and GNOME Disks were enough to prepare the installation USB.

Now let's see what we can do with that old Intel NUC!


Tested on Xubuntu. Debian 13.8 Netinst, amd64. November 2026.