1

I want to SSH to one EC2 instance. I created the key pair using

ec2-add-keypair gsg-keypair

and change the access using

chmod 600 ~/.ec2/id_rsa-gsg-keypair

the keypair is:

-rw------- 1 hduser hadoop  1610 Nov  2 20:20 id_rsa-gsg2-keypair.pem

then I tried to SSH using

ssh -i id_rsa-gsg2-keypair.pem ec2-54-205-100-218.compute-1.amazonaws.com 

and it asked me to enter passphrase

Enter passphrase for key 'id_rsa-gsg2-keypair.pem':

and I do not have it. I tried to run it as root user, same error.I used the full path of the keypair file and got the same error. Finally I tried:

ssh -v id_rsa-gsg2-keypair.pem ec2-54-205-100-218.compute-1.amazonaws.com 

and got this:

debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
ssh: Could not resolve hostname /home/hduser/ec2-api-tools-1.6.11.0/id_rsa-gsg2-keypair.pem: Name or service not known

it would be great if you can help me.

MTT
  • 5,113
  • 7
  • 35
  • 61
  • On your second try with ssh, you forgot the `-i`. Did you add this keypair before or after you created the instance? Is this a key you created? – datasage Nov 03 '13 at 03:59
  • I created the key before I launched the instance. I just used -v to see how it is working! – MTT Nov 03 '13 at 04:04
  • You need to use username in host. `ubuntu@ec2-54-205-100-218.compute-1.amazonaws.com` for ubuntu AMI. `ec2-user@ec2-54-205-100-218.compute-1.amazonaws.com` for Amazon Linux AMI. – Jashwant Nov 07 '13 at 05:45

1 Answers1

0

Firstly i would suggest to keep permission of the key file as 400 as it's too open. If your ami is ubuntu, then user name for ssh login should be ubuntu.

so the command would be like ssh -i key.pem ubuntu@ec2-instace-address

key.pem should contain the entire path to that file /home/ubuntu/.ssh where it's stored or run the above command from .ssh folder.

`

Bijendra
  • 9,467
  • 8
  • 39
  • 66
  • Seems to work with ssh -i -v key.pem ubuntu@ec2-instace-address initially and then without the -v in subsequent requests. – Mukus Jun 01 '17 at 08:08