Wednesday, January 17, 2024

connect to Compute instance on Private Subnet using another Compute instance

 There are many ways using which we can connect to a compute instance running on private subnet and having only private subnet. We can use OCI Bastion service, Secure shell and for enterprise level, we can leverage FastConnect & IPSecVPN. In my previous post Connect to private compute instance, i have shown, how we can connect to a compute instance running on private subnet using public load balancer. The objective of this post is to show, how we can connect to a compute instance running on private subnet using a compute instance running on public subnet in same VCN. This method is very helpful, wherein if we want to do some POCs and want to connect to private compute instance from our desktop machine locally. 


Steps:- I have a VCN named as TEST and inside that i have two subnets one is private and another one is public.




The public subnet has the default security list attached and default route table with Internet gateway enabled.  Next, i created two compute instance, one in public subnet and another one in private subnet.





Then, i will create a new security list for private subnet and edit the security list of private subnet and attach the new security list, which will have ingress from the private IP address of the public compute instance. I will also create a new route table with 0 rules under it and attach it to private subnet.


Security rule for private subnet

ingress:-

egress:-





Now, i will connect to the compute instance on public subnet using putty and i will place the public key in rsa format(for private subnet) in some directory



The rsa format has to be changed using puttygen



Now from the public instance, i should be able to connect to the private instance running on private subnet using its private IP



The above was just a basic way on how we can connect to the private compute instance running on public subnet. This should be helpful when we want to do some small POCs using our local machine.

I hope this post will help someone. Till then, happy learning cloud.