Skip to content

SSH access into PaaS containers: when it is appropriate, when it is not

Shelling into a running PaaS container is a debugging tool, not an operations pattern. Here is the line between legitimate triage and bypassing the platform.

A junior developer opens a ticket: “Can you give me persistent SSH access to the production app container so I can tail logs and fix things when they break?” The answer is no, but the better answer is to explain why — because if you just say no and walk away, the next thing that happens is somebody bakes an SSH daemon into the image, exposes port 22, and bypasses every safeguard the PaaS gives you.

What’s happening

A PaaS container is not a VM. The platform builds it from an image, schedules it on a host you don’t control, and tears it down when the deploy strategy says so. The filesystem inside is mostly ephemeral: anything written outside a declared volume disappears at the next restart. The container is one of N replicas behind a load balancer; the one you shell into is not necessarily representative of the others, and changes you make in-place drift from the deployed image until the next deploy silently undoes them.

There are two legitimate reasons to enter a running container:

  • Live triage of a bug that won’t reproduce locally. Attach to the process, read its memory, inspect file descriptors, see what the application actually has on disk. This is short-lived debugging.
  • Recovering data the application failed to persist. A misconfigured volume mount, a log file the app wrote to a non-shared path before the next deploy nukes it. Pull it out, then fix the configuration.

Everything else — applying a hotfix, running migrations, editing config, restarting a process, “just making it work” — is either a deploy (which goes through the platform pipeline) or a code change (which goes through the repo). Doing those operations from inside a container produces a system whose running state diverges from its source of truth, and the divergence will bite you on the next scale event when the new replica comes up with the old behavior.

The audit trail matters as much as the access. A PaaS exec session that doesn’t appear in your audit log means you cannot answer “who touched the container, when, and what did they do” — which is exactly the question a customer’s compliance review or an incident post-mortem will ask. SSH on port 22 inside the container is not auditable by the PaaS control plane; the platform’s exec API is.

How to verify

Confirm the platform’s exec endpoint logs every session. On Jelastic the audit record is in the dashboard event log:

# Pull recent exec events for an environment
curl -sS -H "Authorization: Bearer ${PAAS_TOKEN}" \
  "https://app.paas.example/1.0/environment/control/rest/getlogs?envName=prod-app&type=exec" \
  | jq -r '.array[] | [.date,.username,.nodeId,.command] | @tsv'

You want to see one row per exec, with the user, the node, and the command. If you don’t see one row per exec — or if you see exec sessions that you can’t attribute to a named human — fix that before anything else.

Check that the container image does not bundle its own SSH server:

# From a built image
docker run --rm --entrypoint sh your-org/app:latest -c \
  'ls /usr/sbin/sshd /usr/bin/ssh /etc/ssh 2>/dev/null; \
   apk info openssh 2>/dev/null; dpkg -l openssh-server 2>/dev/null; \
   rpm -q openssh-server 2>/dev/null'

Empty output is the right answer. If sshd is in the image, somebody added it — either deliberately (and undocumented) or as a transitive dependency of a “fat” base image.

Check that the platform’s exec requires MFA or SSO, not just an API token:

# Should be denied with "MFA required" if the policy is set
curl -sS -H "Authorization: Bearer ${PAAS_TOKEN_NO_MFA}" \
  -X POST "https://api.paas.example/v1/environments/prod-app/exec" \
  -d '{"command":"id"}'

The fix

Four rules, enforced by configuration, not by training docs nobody reads.

1. Disable platform SSH on production environments. Use the PaaS exec API only.

In Jelastic, set the environment’s SSH access to “disabled” in the dashboard, or via API:

curl -sS -H "Authorization: Bearer ${PAAS_TOKEN}" \
  -X POST "https://app.paas.example/1.0/environment/control/rest/setsshaccess" \
  -d "envName=prod-app&enabled=false"

For exec sessions, scope them to a named “operator” role with MFA enforced. Time-bound the session — fifteen-minute limit by default, extendable with a second approval.

2. Bake no SSH server in the image. Add a Dockerfile lint rule:

# Build-time check — fails the build if sshd ends up in the image
RUN if command -v sshd >/dev/null 2>&1 || [ -d /etc/ssh ]; then \
      echo "FATAL: SSH server present in image — remove it"; exit 1; \
    fi

3. Forward every exec session to a SIEM. The PaaS audit log alone is not enough — you want centralized retention beyond the platform’s window:

# Example: forward Jelastic audit logs to Loki via vector
sources:
  paas_audit:
    type: http_client
    endpoint: https://app.paas.example/1.0/environment/control/rest/getlogs
    headers:
      Authorization: "Bearer ${PAAS_TOKEN}"
    query:
      type: ["exec","sshaccess"]
    interval_secs: 60

sinks:
  loki:
    type: loki
    endpoint: https://loki.internal:3100
    inputs: [paas_audit]
    labels:
      job: paas_audit

4. Make the platform exec the path of least resistance. If kubectl exec or the platform CLI is two clicks and an MFA prompt, while SSH-into-the-container is three steps of bypass effort, operators will use the audited path. If the audited path is harder, they won’t.

The corollary rule for engineering culture: any production change that requires entering a container is a deploy bug. Add it to the post-mortem. The container is supposed to be the artifact of a pipeline; if you cannot reproduce the production state from git checkout && deploy, the gap is the bug, not the exec session that papered over it.

Stack Harbor sets up PaaS environments with audited exec, MFA-gated operator access, and SIEM forwarding included on every account through managed PaaS. If your platform’s audit trail today is “the dashboard, sometimes”, start a hardening review.