In today's blog, we shall learn how to access the instances in a Public subnet.
Since the servers are in the private subnet, we cannot directly reach to these. We will use a bastion host - this is a server that will be deployed in the public subnet. We can access the private subnet through this.
Let us first create an EC2 instance which will from now be referred to as Bastion host in the public subnet, SSH into this. Then from this server, we will be able to SSH and connect to the instances in the private subnet.
Go to EC2 home page>Instances>Create Instance
Name the instance, select the ami
Scroll down>Select the instance type>Key pair
Scroll furthermore, select the VPC that we created in the last blog > Be sure to select public subnet and enable auto assigning IP address since this EC2 shpuld be created in the Public subnet
Next, create a security group that will allow ssh access to this instance and create on Launch Instance.
Check if the instance is successfully launched
Before logging in to this instance we shall first copy our pem file from our local to Bastion host as we will need this to further login to our private instances via the Bastion host
We shall then login into the Bastion host and check if pem file has been copied
The PEM file is successfully copied. Let us now check if we can log in to our instances in the public subnet through this server
We have successfully logged into the instance in a private subnet, the same method can be followed to log into the instance in the public subnet as well. In the next blog, we shall learn how to deploy a simple Python server in these instances