OCI Bastion Service Part I: How to Use it to Connect to Your Private Subnet (Console)
Kosseila Hd
Mar 30, 2022 2:45:00 PM
In the Cloud, Bastion or Jump Server is the only node exposed to the outside world and acts as a gateway between the Private Network where your backend resources (application, databases, and other applications) are hosted and the Internet. A Bastion runs bare minimum applications and is extremely secure. Even if any network can access it, it is still fortified against illegal entry and attack.
But what if there was another disruptive way to provide that sort of remote access without needing to configure a VM (Virtual Machine) in a Public Subnet?
A quick table of contents
– What is Bastion Service and Why is it, Revolutionary
– Create Bastion Service using the Console
Let me demonstrate why OCI Bastion (Oracle Cloud Infrastructure) service makes your life easier. Imagine every team in your organization wanting their own Bastion VM because they’re no fan of sharing their stuff with others. For each of your teams you would have to:
Why OCI Bastion Service is better than other provider’s equivalent offerings
With the Oracle Bastion service, not only will you not need to worry about creating, hardening or paying for a Bastion VM anymore but also the service is FREE and you won’t have to install any agent or grant permissions.
Let’s see how to create the Bastion service through the Console, OCI CLI, and Terraform. The Bastion service is linked to the target subnet and a Bastion session will define the port forwarding to the target instance.
Our environment :
– VCN vcnterra has the private subnet db-sub with a CIDR of 192.168.78.0/24
– DB instance IP is 192.168.78.10
CIDR allowlist: 0.0.0.0/0 means you can SSH the DB instance from anywhere.
We will now create the Bastion session where we will define the forwarded port through the tunnel and the target IP
Note:
There are two session types, SSH Managed which requires a cloud agent and port forwarding session which we need.
You can either generate, upload, or paste your SSH public key.
# ssh -i ~/.ssh/id_rsa_oci -N -L 22:192.168.78.10:22 -p 22 ocid1.bastionsession.oc1.ca-toronto-1.amaaaaaavr**a@host.bastion.ca-toronto-1.oci.oraclecloud.com &
# ssh -i ~/.ssh/id_rsa_dbcs opc@localhost
[opc@hopsdb-oci ~]$ cat /etc/redhat-release --- target instance
Red Hat Enterprise Linux Server release 7.9 (Maipo)
[opc@hopsdb-oci ~]$ ifconfig ens3
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9000
inet 192.168.78.10 netmask 255.255.255.0 broadcast 192.168.78.255
In this article, we learned:
Fill out the form below to unlock access to more Eclipsys blogs – It’s that easy!