Connecting to a server using the OCI Bastion Service
OCI Bastion Service
- Allows to securely access a private cloud instance without exposing a public IP address to the internet.
- Provides a fully managed, time-limited gateway that acts as a secure bridge
Step 1: Enable the Bastion Agent
- Instances -> server1 -> Management -> Oracle Cloud Agent
- Bastion: Enabled
- For the cloud agent to communicate properly, private subnet's Route Table must have a rule pointing to a NAT Gateway or a Service Gateway so it can reach Oracle's internal infrastructure
- Private virtual machine (VM) can talk to Oracle's internal infrastructure and keep the Bastion plugin running, need to add a route rule.Phase 1: Create the Service Gateway
- zyn-vcn -> Ggateway -> Service Gateways -> Create Service Gateway
- Name: zyn_svc_gateway
- Services: All SYD Services In Oracle Services Network
- Create Service Gateway
Phase 2: Add the Rule to your Private Subnet's Route Table- zyn-vcn -> Routing -> Route table -> Default route-table for zyn-vcn -> Route Rules -> Add Route Rules
- Target Type: Service Gateway.
- Destination Service: OCI SYD Object Storage
- Target Service Gateway: zyn_svc_gateway
Phase 3: Verify the Security ListThe gateway allows data to travel, but your firewall rules must allow it to leave the VM.- zyn-vcn -> Security -> Security List -> Default Security List for zyn-vcn -> Security Rules -> Egress Rules -> Add Egress Rules
- Destination type: Service
- Destination Service: All SYD Services In Oracle Services Network
- IP Protocol: All
Wait for 5 to 10 minutes to sync up, then try starting a new Bastion session.
Step 2: Create the OCI Bastion Gateway
Build the Bastion service container
- Hamburger Menu -> Identity & Security -> Bastion -> Create Bastion.
- Name: zynBastion
- Target VCN: zyn-vnc
- Target Subnet: zyn-public-subnet
- CIDR Block Allowlist:
0.0.0.0/0/ own ip - Click Create Bastion
Step 3: Update Subnet Firewall Rule
Subnet's firewall must trust incoming traffic sent by the Bastion.
- Bastion -> zynBastion -> copy the Private Endpoint IP Address. (10.0.1.70)
- zyn-vcn -> security -> security list -> Default security list for zyn-vcn
- Security rules -> Add Ingress Rule
- Source Type:
CIDR - Source CIDR: Paste the Private Endpoint IP Address (10.0.1.70/32)
- IP Protocol:
TCP - Destination Port Range:
22
- Click Add Ingress Rule.
Step 4: Create a Bastion Session
- Identity & Security -> Bastion -> zynBastion -> Sessions -> Create Session.
- Session Type: Managed SSH Session
- Session name: zyn_session
- Username: opc
- Target Compute Instance: server1
- Add SSH Key: Upload or paste the Public Key (
.pub) file - Create Session
Step 5: Connect From Local Terminal
Use the pre-built connection link provided by Oracle Cloud.
- Bastion -> zynBastion -> sessions -> zynsessions -> 3 dots (...) -> view/copy ssh command ->
- Open the Terminal / PowerShell
- Paste the command into a text editor first and fix the placeholders:
- Replace
<privateKey>with the actual path to your downloaded private key file
- Replace
- Press Enter to execute the command in your terminal.
- sudo su - # to login as root user
===============================================================
Comments
Post a Comment