Launch EC2 Instance On Amazon Cloud Using Private subnets
In our previous article, we have already created EC2 instances for public subnets. Now I will use private subnets to launch EC2 instance. you can launch servers in private subnets in AWS.
You can directly be connected to the internet using public subnets because you keep the servers that will be facing public traffic.
You can follow the steps to launch the server, I’m skipping a few steps
Click on Launch -> launch instance -> choose Linux AMI -> Instance type
Now you need to choose your VPC network and Private subnets here
Add storage to install the Linux OS
Define a tag to recognize the server later and Give it any name.
You need to create a security group separately for your private server. In inbound rules, you need to define the IP or network. So servers that are in other subnets can talk to your private servers. You can’t directly access your private subnets servers.
Now review your server configuration and choose a key to launch the server. I used an already existing key pair. You can use the same key for all your servers.
Your instance created for private subnets.
If you want to access your private subnets server, you need to come on public then do ssh to private servers. Now access your public server instance.
You will need a pem key to access the private servers from the public and paste the key in this file.
Change file permission,
chmod 600 websrv.pem
Now login to your private subnet server using the below command.
ssh -i websrv.pem firstname.lastname@example.org
You have successfully logged in to the private server which has the IP 10.0.2.171 and makes sure port 22 should be open on the private subnets and network or IP should be whitelisted to connect the server within your network.