After you have created an EC2 instance at Amazon AWS, you can access the instance via ssh. In order to do so, you need two pieces of information: (1) private key file associated with your instance and (2) public DNS of your instance.
The private key file for your EC2 instance should have become available to you while you went through creating the instance via Request Instances Wizard on EC2 Management Console. During EC2 instance creation, Request Instance Wizard prompts you to choose public/private key pair for your instance (either choose from existing key pairs or create a new key pair).
When you ssh to your EC2 instance, you need to use the same private key that you downloaded from Amazon EC2. You can download a private key only at the very first time you create a new key pair, and you cannot retrieve it later on. So make sure to store the private key in a safe place.
Next, you need to know the public DNS of your instance. For that, go to EC2 Management Console, and click your instance.
Once you obtained the public DNS of your EC2 instance, you can ssh to the instance as follows. I assume that the private key for the instance is named "xmodulo.pem".
$ ssh -i xmodulo.pem ec2-107-22-3-248.compute-1.amazonaws.com
Changing the access permission of your private key is necessary for ssh access on EC2. Otherwise, you will get the following error.
Permissions 0664 for 'xmodulo.pem' are too open. It is required that your private key files are NOT accessible by others.
If you want, you can use ssh configuration file to automatically force you to use a particular private key to ssh to your EC2 instance, instead of manually specifying the private key using "-i" option.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to install Suricata intrusion detection system on Linux - September 3, 2015
- How to switch from NetworkManager to systemd-networkd on Linux - August 31, 2015
- How to set up a system status page of your infrastructure - August 25, 2015