Skip to content

Lesson 6 of 9 · 25m

Bastion Patterns and Administrative Paths

Design bastions as narrow, auditable administrative chokepoints rather than magical jump boxes that quietly inherit all trust.

Every environment eventually grows a jump box. At first it is convenient. Then it accumulates private keys, sudo rights, agent forwarding, copy-pasted secrets, and SSH exemptions until it becomes the highest-value target in the network. A bastion can still be a good architecture, but only when it is narrow, ephemeral in trust, and obsessively auditable.

A bastion is an enforcement point, not a trust oracle

The purpose is to concentrate administrative entry so policy, logging, session recording, network filtering, and access workflow are easier to enforce. The purpose is not to make everything behind it trusted. Internal services should still authenticate administrators and authorize actions.

A minimal SSH bastion configuration should disable forwardings you do not need:

AllowTcpForwarding no
AllowAgentForwarding no
PermitTunnel no
X11Forwarding no
PermitUserEnvironment no
MaxSessions 4

If operators genuinely need controlled forwarding, allow it for a dedicated group and document the use case. Convenience features are exactly what attackers use for lateral movement.

Prefer short-lived credentials

Do not place a bag of private keys on the bastion. Use SSH certificates or a controlled signing service. A practical user flow:

ssh -o CertificateFile=~/.ssh/id_ed25519-cert.pub     -J sre@bastion.sudosecurity.org traven@10.20.4.13

The target host must trust the user CA and enforce certificate principals. The bastion need not possess target private keys. This separation matters: stealing the bastion should not automatically hand over the fleet.

Restrict egress ruthlessly

A bastion needs outbound SSH to approved administrative ranges and little else. It probably does not need package manager access all day, arbitrary internet browsing, or direct cloud metadata credentials. Use host firewall rules and network security groups together:

iptables -A OUTPUT -p tcp -d 10.20.0.0/16 --dport 22 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -d 10.44.0.2 -j ACCEPT
iptables -A OUTPUT -j DROP

Real production rules need state handling and IPv6 treatment, but the design principle stands: default deny outbound, then permit named administrative paths.

Record sessions without pretending recordings are enough

auditd, pam_tty_audit, commercial session recorders, shell logging, and target-host authorization logs all help. Session recording is useful for investigations and deterrence, but it does not establish intent. Prefer structured authorization events: who requested access, approved by what policy, to which host, for how long.

Harden the lifecycle

Bastions should be patched aggressively, rebuilt from immutable configuration, separated by environment, and small enough that no one installs a wiki, a debugger, or "just one" convenience dashboard. Break-glass accounts must be rare, monitored, and tested.

Field notes

  • Agent forwarding through a bastion exposes usable credentials to a compromised intermediate host.
  • -J ProxyJump does not require shell access on the intermediate by itself; constrain accounts anyway.
  • Do not make the bastion the only place where authorization exists; target hosts should enforce identity too.
  • Emergency access that bypasses all logging will eventually become normal access.

Was this lesson helpful?

Sign in to rate