Wednesday, February 3, 2016

amazon web services - Connecting a server in a private subnet from a server in the public subnet



I created 2 subnets in one AWS VPC. One of them has an internet gateway for routing. The other has a NAT gateway.



I launched 1 instance into the public subnet with a public IP address and the other into the private subnet with only a private IP address.




Now, to make any updates, to install any packages or to configure the server to make it as a database server, how do I access it from the instance in the public subnet(considering the instance in the public subnet to be the application server).



I am not able to SSH to it. I get the error as in this image:ssh-error


Answer



To SSH from a bastion host to a private server, upload the key file to the bastion host and use the following command



$ssh -i /home/ubuntu/keyfile.pem ec2-user@11.0.154.1



Also, while doing this ensure that the file permission of the key file is 400. We can also use SSH port forwarding to establish this connection



No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...