Typically I set ssh aliases as follows:
ssh -i ~/path/key.pem [email protected]
But with EC2 instances, the public-host-name
changes whenever an instance is stopped and restarted.
My EC2 instances are on a VPN and have constant private IPs. What strategy can I use so that I can log into my instances without constantly changing the alias?
Thanks!
You have to use a Dynamic DNS solution for this.
You could use a DNS provider or configure your own Dynamic DNS server (there are a lot of tutorials for this). There are also scripts for using Route53 for this.
The Private IP is not accessible from outside the AWS network and is only useful when you have a cluster of EC2 instances for communication between them with-in your security group.
You could assign a Elastic IP to the instance or use a Dynamic DNS Solution.