azurebox is built FROM lqdflying/osbox:5.0. It inherits the general network diagnostics, SSH setup, Python 3.13/pip, requests and jq from osbox, and adds Azure CLI, PostgreSQL 17 client, psycopg, qpid-proton, PyJWT and cryptography. Access uses the services' public protocols — no azure-* SDK. It is meant for interactive testing, including as a pod in AKS.
| Tag | Digest | Compressed |
|---|---|---|
lqdflying/azurebox:1.1 | sha256:af81fbf2f62e3074e5a6254818ebb9dea71266bca9ec1b344b221abbae4fdbd9 | ~330 MiB |
lqdflying/azurebox:latest | same as 1.1 | ~330 MiB |
lqdflying/azurebox:1.0 | sha256:c8e2e42c907413e46594ccad2a24f0bb19dc95bda8b1e8b98199c78339f1b60a | ~330 MiB |
base lqdflying/osbox:5.0 | sha256:3ecafacc1740fa0f09dd6974838c5f4fa49d77c478f546e0837296b80233da1e | ~193 MiB |
1.0 was a one-time copy of osbox 4.2 made before the repo split; 1.1 is the first layered build on the general osbox base. The Dockerfile is FROM lqdflying/osbox:5.0 and adds only Azure-specific tooling.
Pin the digest in AKS for reproducible test pods:
image: lqdflying/azurebox@sha256:af81fbf2f62e3074e5a6254818ebb9dea71266bca9ec1b344b221abbae4fdbd9
docker run -d --name azurebox \
-p 127.0.0.1:2222:22 \
-v azurebox-ssh:/etc/ssh \
lqdflying/azurebox:1.1
The container generates a random password on every start and prints it to the log:
docker logs azurebox | grep -i password
# or
docker exec azurebox cat /tmp/password.txt
Connect as liuqd or root (both use the same generated password):
ssh -p 2222 [email protected]
ssh -p 2222 [email protected]
For a shell without SSH, use docker exec:
docker exec -it azurebox bash
The default run/compose mapping is loopback only. Do not change it to 0.0.0.0:22.
Prerequisites: the AKS cluster has OIDC issuer and workload identity enabled, and the managed identity or app registration has a federated credential whose subject is system:serviceaccount:<namespace>:azurebox.
apiVersion: v1
kind: ServiceAccount
metadata:
name: azurebox
namespace: default
annotations:
azure.workload.identity/client-id: "<managed-identity-client-id>"
---
apiVersion: v1
kind: Pod
metadata:
name: azurebox
namespace: default
labels:
azure.workload.identity/use: "true"
spec:
serviceAccountName: azurebox
restartPolicy: Never
containers:
- name: azurebox
image: lqdflying/azurebox:1.1
ports:
- containerPort: 22
env:
- name: AZURE_STORAGE_ACCOUNT
value: "<storage-account>"
- name: AZURE_KEYVAULT_URL
value: "https://<vault-name>.vault.azure.net/"
- name: AZURE_EVENTHUB_FQDN
value: "<namespace>.servicebus.windows.net"
- name: AZURE_EVENTHUB_NAME
value: "<event-hub>"
- name: AZURE_PG_HOST
value: "<server>.postgres.database.azure.com"
- name: AZURE_PG_DATABASE
value: "postgres"
- name: AZURE_PG_USER
value: "<entra-principal-name>"
The workload identity webhook injects AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_AUTHORITY_HOST and AZURE_FEDERATED_TOKEN_FILE. Do not set those manually.
There is deliberately no Service in the manifest. Port 22 listens inside the pod but is not reachable unless you route to it.
Prefer kubectl exec — it inherits the pod environment, including the workload identity variables. The container runs as root, so the projected token file is readable there:
kubectl apply -f azurebox.yaml
kubectl exec -it azurebox -- bash
If you really need SSH (test VM behavior only):
kubectl port-forward pod/azurebox 2222:22
kubectl logs azurebox | grep -i password
ssh -p 2222 [email protected]
Use kubectl port-forward rather than a LoadBalancer or NodePort Service. SSH sessions do not inherit the pod environment (PermitUserEnvironment no), so for workload identity work always use kubectl exec.
The password rotates on every container restart. Host keys come from the image unless you mount a unique /etc/ssh volume; in AKS an emptyDir there would leave sshd without host keys, so leave /etc/ssh alone or mount your own keys.
| Category | Tools |
|---|---|
| Network | nmap, nc, socat, mtr, traceroute, tcptraceroute, httping, arping, iperf3 |
| DNS / HTTP / TLS | dig, nslookup, host, whois, curl, wget, openssl |
| Capture / decode | tcpdump, tshark, ngrep |
| Firewall / NAT | iptables, nft, conntrack, brctl |
| Sockets / system | ss, netstat, lsof, strace, ethtool, nload, iftop |
| Cloud / database | az (Azure CLI), psql, pg_dump, pg_restore, pg_isready, createdb, dropdb |
| Python | Python 3.13, pip, requests, psycopg, qpid-proton (import proton), PyJWT, cryptography |
| Other | jq, vim, sudo, openssh-client/server |
pip install <package> works system-wide inside the container (/etc/pip.conf sets break-system-packages = true). Useful additions for Event Hubs Kafka testing: pip install confluent-kafka.
The services are reached over their public protocols. Token acquisition is standard OAuth2; no Azure SDK is involved.
| Target | Scope |
|---|---|
| Azure Resource Manager | https://management.azure.com/.default |
| Blob Storage | https://storage.azure.com/.default |
| Key Vault | https://vault.azure.net/.default |
| Event Hubs | https://eventhubs.azure.net/.default |
| PostgreSQL | https://ossrdbms-aad.database.windows.net/.default |
This handles AKS workload identity, a client secret, or IMDS managed identity, in that order:
import os
import requests
def get_token(scope):
"""Return an Entra access token for scope, with no Azure SDK."""
fed = os.environ.get("AZURE_FEDERATED_TOKEN_FILE")
if fed:
tenant = os.environ["AZURE_TENANT_ID"]
authority = os.environ.get(
"AZURE_AUTHORITY_HOST", "https://login.microsoftonline.com"
).rstrip("/")
with open(fed) as fh:
assertion = fh.read().strip()
url = f"{authority}/{tenant}/oauth2/v2.0/token"
data = {
"grant_type": "client_credentials",
"client_id": os.environ["AZURE_CLIENT_ID"],
"scope": scope,
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"client_assertion": assertion,
}
elif os.environ.get("AZURE_CLIENT_SECRET"):
tenant = os.environ["AZURE_TENANT_ID"]
url = f"https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token"
data = {
"grant_type": "client_credentials",
"client_id": os.environ["AZURE_CLIENT_ID"],
"client_secret": os.environ["AZURE_CLIENT_SECRET"],
"scope": scope,
}
else:
params = {
"api-version": "2018-02-01",
"resource": scope.removesuffix("/.default") + "/",
}
if os.environ.get("AZURE_CLIENT_ID"):
params["client_id"] = os.environ["AZURE_CLIENT_ID"]
r = requests.get(
"http://169.254.169.254/metadata/identity/oauth2/token",
params=params,
headers={"Metadata": "true"},
timeout=10,
)
r.raise_for_status()
return r.json()["access_token"]
r = requests.post(url, data=data, timeout=30)
r.raise_for_status()
return r.json()["access_token"]
Tokens are valid for roughly an hour. Acquire one per test; never write it to a shared file or print it.
Acquire a token with scope https://storage.azure.com/.default:
token = get_token("https://storage.azure.com/.default")
List containers:
from email.utils import formatdate
import xml.etree.ElementTree as ET
import requests
def blob_containers(account, token):
r = requests.get(
f"https://{account}.blob.core.windows.net/",
params={"comp": "list"},
headers={
"Authorization": f"Bearer {token}",
"x-ms-version": "2023-11-03",
"x-ms-date": formatdate(usegmt=True),
},
timeout=30,
)
r.raise_for_status()
root = ET.fromstring(r.text)
return [e.text for e in root.iter() if e.tag.endswith("Name")]
Equivalent shell check:
curl -sS "https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/?comp=list" \
-H "Authorization: Bearer ${TOKEN}" \
-H "x-ms-version: 2023-11-03" \
-H "x-ms-date: $(date -u '+%a, %d %b %Y %H:%M:%S GMT')" \
| python3 -c 'import sys, xml.etree.ElementTree as ET; root = ET.fromstring(sys.stdin.read()); print("\n".join(e.text for e in root.iter() if e.tag.endswith("Name")))'
Read a blob with GET https://<account>.blob.core.windows.net/<container>/<blob>. Upload with PUT plus x-ms-blob-type: BlockBlob. URL-encode container and blob names. Blob data-plane RBAC: Storage Blob Data Reader or Storage Blob Data Contributor.
Acquire a token with scope https://vault.azure.net/.default:
token = get_token("https://vault.azure.net/.default")
List secret names (never values):
def kv_secret_ids(vault_url, token):
r = requests.get(
f"{vault_url.rstrip('/')}/secrets",
params={"api-version": "7.4", "maxresults": 25},
headers={"Authorization": f"Bearer {token}"},
timeout=30,
)
r.raise_for_status()
return [item["id"] for item in r.json().get("value", [])]
Read one secret:
r = requests.get(
f"{vault_url.rstrip('/')}/secrets/{name}",
params={"api-version": "7.4"},
headers={"Authorization": f"Bearer {token}"},
timeout=30,
)
r.raise_for_status()
value = r.json()["value"] # sensitive: do not log or paste
Shell equivalent:
curl -sS "https://<vault>.vault.azure.net/secrets?api-version=7.4&maxresults=5" \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.value[]?.id'
RBAC note: Key Vault Secrets User allows reading a secret but may not allow listing all secrets. A 403 on list with a successful GET of a known secret name is expected. az keyvault secret show prints the secret value.
Acquire a token with scope https://eventhubs.azure.net/.default (also used as the CBS token for AMQP):
token = get_token("https://eventhubs.azure.net/.default")
Send one event over HTTPS REST (this writes to the hub):
def eventhub_send(fqdn, hub, token, event):
r = requests.post(
f"https://{fqdn}/{hub}/messages",
params={"api-version": "2014-01", "timeout": 60},
headers={"Authorization": f"Bearer {token}"},
json=event,
timeout=30,
)
r.raise_for_status()
return r.status_code # 201 Created
Receiving is AMQP 1.0 only. qpid-proton is installed for that (import proton). Event Hubs uses CBS authentication:
amqps://<namespace>.servicebus.windows.net:5671.$cbs node.put-token message with application properties operation=put-token, type=jwt, name=sb://<namespace>.servicebus.windows.net/, expiration=<epoch-milliseconds> and the access token as the body.If the namespace has the Kafka endpoint enabled, confluent-kafka with SASL OAUTHBEARER is an alternative (pip install confluent-kafka).
The Entra token is the password; TLS is required. The user name must match the Entra principal that has a database role (pgaadauth_create_principal('<name>', false, false)), and the server must have an Entra admin configured.
import os
import psycopg
token = get_token("https://ossrdbms-aad.database.windows.net/.default")
with psycopg.connect(
host=os.environ["AZURE_PG_HOST"],
dbname=os.environ.get("AZURE_PG_DATABASE", "postgres"),
user=os.environ["AZURE_PG_USER"],
password=token,
sslmode="require",
connect_timeout=10,
) as conn:
with conn.cursor() as cur:
cur.execute("select current_user, current_database()")
print(cur.fetchone())
With psql after an Azure CLI login:
az login --service-principal \
--username "$AZURE_CLIENT_ID" \
--tenant "$AZURE_TENANT_ID" \
--federated-token "$(cat "$AZURE_FEDERATED_TOKEN_FILE")"
PGPASSWORD="$(az account get-access-token --resource-type oss-rdbms --query accessToken -o tsv)" \
psql "host=$AZURE_PG_HOST dbname=$AZURE_PG_DATABASE user=$AZURE_PG_USER sslmode=require"
A 28P01 authentication failure usually means the user string does not match the database role name, not that the token is invalid.
# Workload identity
az login --service-principal \
--username "$AZURE_CLIENT_ID" \
--tenant "$AZURE_TENANT_ID" \
--federated-token "$(cat "$AZURE_FEDERATED_TOKEN_FILE")"
# Managed identity (IMDS; not the workload identity path)
az login --identity
az account show --query '{user:user.name, tenant:tenantId}' -o json
az account get-access-token --scope https://storage.azure.com/.default --query accessToken -o tsv
az storage container list --account-name "$AZURE_STORAGE_ACCOUNT" --auth-mode login -o table
az keyvault secret list --vault-name "<vault>" -o table
az postgres flexible-server list -o table
azurebox is a derived image: FROM lqdflying/osbox:5.0. Rebuild and push the osbox base first when general tools change, then:
cd /root/azurebox
docker build -t lqdflying/azurebox:1.1 .
docker tag lqdflying/azurebox:1.1 lqdflying/azurebox:latest
docker push lqdflying/azurebox:1.1
docker push lqdflying/azurebox:latest
kubectl exec -it azurebox -- env | grep ^AZURE_ and ls -l "$AZURE_FEDERATED_TOKEN_FILE". If the variables are missing, check the pod label and the service account annotation.401 Unauthorized: token audience/scope is wrong, the token expired, or the federated credential subject does not match the service account. Decode the token claims (aud, exp) without printing the token itself.403 AuthorizationPermissionMismatch: the identity authenticated but lacks the data-plane role at that scope. Check role assignments: Storage Blob Data Reader/Contributor, Key Vault Secrets User, Event Hubs Data Sender/Receiver.403 but get works: expected for Key Vault Secrets User; use a known secret name.AZURE_PG_USER role name and that the server has an Entra admin.dig +short <host>, nc -vz <host> 443, curl -v https://<host>/, openssl s_client -connect <host>:443 -servername <host>.eventhubs.azure.net scope, not the Service Bus management scope.kubectl exec or export the variables manually.nohup <cmd> >/tmp/test.log 2>&1 &.azurebox inherits osbox's intentionally unhardened behavior: root SSH login, password authentication, a generated password printed to the container log and stored in /tmp/password.txt, and passwordless sudo for liuqd. Treat it as a trusted-network test VM.
kubectl exec or kubectl port-forward.docker rm -f azurebox
# compose prefixes the name, e.g. azurebox_azurebox-ssh; list before removing
docker volume ls --filter name=azurebox-ssh
kubectl delete -f azurebox.yaml
Content type
Image
Digest
sha256:af81fbf2f…
Size
330.1 MB
Last updated
9 days ago
docker pull lqdflying/azurebox