Connect to EC2 instance using SSH and Ubuntu terminal
Assuming you have a Key Pair file .pem already created in EC2 management
console, connect to your instance, in my case Ubuntu 12.04.2 LTS 64
with this command:
where ec2.pem should be name of your key file, this command works only if you are in the directory where .pem file is stored, otherwise use ssh -i /home/Downloads/your_key_name.pem ...
ubuntu is the default user name used on EC2 instances with Ubuntu default AMIs.
ec2-23-22-122-111.compute-1.amazonaws.com is Public DNS, you can find it in EC2 management console > Instances > Description.
First time you will be asked to trust public key, replay by writing whole word "yes".
Hit Enter and then you will be connected.
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
$ ssh -i ec2.pem ubuntu@ec2-23-22-122-111.compute-1.amazonaws.com
where ec2.pem should be name of your key file, this command works only if you are in the directory where .pem file is stored, otherwise use ssh -i /home/Downloads/your_key_name.pem ...
ubuntu is the default user name used on EC2 instances with Ubuntu default AMIs.
ec2-23-22-122-111.compute-1.amazonaws.com is Public DNS, you can find it in EC2 management console > Instances > Description.
First time you will be asked to trust public key, replay by writing whole word "yes".
The authenticity of host '23.22.122.111 (23.22.122.111)' can't be established.
ECDSA key fingerprint is 55:1b:99:99:a4:9c:eb:94:fd:7b:4f:11:5b:bf:94:7d.
Are you sure you want to continue connecting (yes/no)? yes
ECDSA key fingerprint is 55:1b:99:99:a4:9c:eb:94:fd:7b:4f:11:5b:bf:94:7d.
Are you sure you want to continue connecting (yes/no)? yes
Hit Enter and then you will be connected.
Warning about permission too pen is solved by chmod 400:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0664 for 'ec2.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: ec2.pem
Permission denied (publickey).
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: ec2.pem
Permission denied (publickey).
Using same Key Pair for more EC2 instances in multiple regions and zones
You do not have to create new Key Pair for every zone or region or instance, instead, use Key Pair Import
and use the same on everywhere, it is a time-saver and I do not see the
security issue, once you loose any of them it is too bad.
Comments
Post a Comment