11.2 OCI Bastion: Managed SSH, Port Forwarding & SOCKS5 Sessions

Key Takeaways

  • OCI Bastion provides restricted, time-limited SSH-based access to target resources that don't have public endpoints, and bastions do not incur costs.

  • A managed SSH session requires a Linux platform image, a running OpenSSH server, and the Oracle Cloud Agent with the Bastion plugin enabled.

  • SSH port forwarding sessions need neither an OpenSSH server nor the Oracle Cloud Agent on the target, so they work for databases and Windows RDP.

  • A dynamic port forwarding (SOCKS5) session tunnels to a target subnet, and the client chooses which host and port to reach.

  • A bastion's maximum session time-to-live can be set from 30 minutes to 180 minutes (3 hours).

Last updated: October 2026

Why Bastion Replaces Jump Hosts

A traditional jump host is a VM with a public IP that administrators SSH into before reaching private servers. It exposes port 22 to the internet, needs patching and user management, and runs all the time. OCI Bastion is an Oracle-managed service that provides restricted and time-limited access to target resources without public endpoints. Bastions do not incur costs, although they have service limits.

You cannot SSH directly into a bastion or administer it like a host. Instead, you create sessions through it.

Bastions and Sessions

ConceptDescription
BastionA resource attached to a target VCN and subnet. It defines the client CIDR block allowlist (the IP ranges that may connect) and the maximum session time-to-live (TTL).
SessionA time-limited connection to one target. You provide the public key of an SSH key pair when you create it, and connect with the matching private key.
Client CIDR allowlistConnections are accepted only from these addresses, for example a corporate VPN egress range.

To use a session, a user needs IAM permission, the private key that matches the public key in the session, and a client IP inside the allowlist.

The Three Session Types

1. Managed SSH Session

A managed SSH session gives SSH access to a compute instance. The instance must:

  • Run a Linux platform image (Windows is not supported).
  • Run an OpenSSH server.
  • Run the Oracle Cloud Agent with the Bastion plugin enabled.

The agent is enabled by default on instances created from many Oracle-provided images, but the Bastion plugin is not enabled by default, so you must turn it on before creating a session. Bastion relies on the plugin to set up access on the instance for the life of the session.

2. SSH Port Forwarding Session

An SSH port forwarding session (SSH tunneling) connects a port on your client machine to a specific port on a target IP address or DNS name. It does not need an OpenSSH server or the Oracle Cloud Agent on the target, so it works for:

  • Databases: for example, connecting Oracle SQL Developer to the private endpoint of an Autonomous AI Transaction Processing database.
  • Windows servers: tunneling RDP on port 3389.
  • Web consoles or any other TCP service on a private IP.

A typical connection command looks like this:

ssh -i <private-key> -N -L <local-port>:<target-private-ip>:<target-port> -p 22 <session-ocid>@host.bastion.<region>.oci.oraclecloud.com

3. Dynamic Port Forwarding (SOCKS5) Session

A dynamic port forwarding session gives the same benefits as SSH port forwarding, but instead of one fixed target it creates a tunnel to a target subnet. Your client (for example, a browser configured to use a SOCKS5 proxy) then decides which resource and port to reach. This suits administrators who need to reach several private web consoles during one maintenance window.

Session typeTargetNeeds OpenSSH on targetNeeds Oracle Cloud Agent + Bastion pluginTypical use
Managed SSHOne Linux instanceYesYesShell access to Linux VMs
SSH port forwardingOne IP or DNS name and portNoNoDatabases, RDP, single web consoles
Dynamic port forwarding (SOCKS5)A subnetNoNoSeveral private services through one tunnel

Time-to-Live Limits

Sessions are temporary by design. The bastion's maximum session TTL can be set from a minimum of 30 minutes to a maximum of 180 minutes (3 hours), and each session can have its own TTL up to that maximum. When the TTL expires, the session ends and the user must create a new session. You can also delete a session before it expires. Setting the bastion-level TTL to the shortest practical value limits how long a stolen private key could be useful.

Network Design

  • Create the bastion with the target subnet where the resources are, or a subnet with routes to them.
  • Add security rules or NSG rules on the targets that allow SSH (port 22) or the forwarded ports from the bastion's private IP in the target subnet.
  • Keep the client CIDR allowlist as narrow as possible. Avoid 0.0.0.0/0.

Access Control and Monitoring

  • IAM policies control who can create bastions and sessions. Separate the people who manage bastions from the people who only create sessions, and scope permissions to compartments.
  • OCI Audit records every call to the Bastion API, such as session creation, including the requesting principal.
  • Monitoring provides Bastion metrics, and Events let you react when bastions or sessions change state.
  • Cloud Guard activity detectors include rules for "Bastion created" and "Bastion session created", which can alert the security team.

Oracle also recommends integrating target instances with IAM and multifactor authentication and auditing Bastion operations as part of securing the service.

Loading diagram...
Bastion Session Types
Test Your Knowledge

A DBA must connect SQL Developer from the office to an Autonomous AI Database that has only a private endpoint. Company policy forbids permanent jump hosts, requires sessions to expire after two hours, and allows connections only from the office egress range. What should the architect set up?

A

A Bastion allowing the office CIDR, with a port forwarding session to the database's private IP

B

A Bastion managed SSH session that targets the database OCID with a 2-hour TTL

C

A public load balancer whose listener forwards port 1522 to the database's private endpoint IP

D

A small Linux VM with a public IP in a public subnet that is stopped every evening

Test Your Knowledge

A managed SSH session to a private Oracle Linux instance fails to become active. The instance runs OpenSSH and the Oracle Cloud Agent. What is the most likely missing step?

A

Assigning a public IP address to the target instance

B

Changing the session type to dynamic port forwarding (SOCKS5)

C

Enabling the Bastion plugin of the Oracle Cloud Agent

D

Raising the bastion's maximum session TTL above 3 hours

Test Your Knowledge

During a maintenance window, an engineer needs to open several internal web consoles on different private hosts in one subnet, without creating a separate session for each host. Which Bastion session type fits?

A

Managed SSH session

B

SSH port forwarding session

C

A session with a TTL longer than 3 hours

D

Dynamic port forwarding (SOCKS5) session

Sections you finish are checked off in the contents.