Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permissions error when connecting to EC2 via SSH on Mac OSx

I am new to EC2. I created my security credentials from this site:

http://paulstamatiou.com/how-to-getting-started-with-amazon-ec2

It worked great, I rebooted and now when I try to connect I get a login/password prompt. (Which I never set up.) After several attempts I get this error:

Permission denied (publickey,gssapi-with-mic).

What am I doing wrong?

like image 527
Josh Scott Avatar asked Feb 01 '10 19:02

Josh Scott


People also ask

How do I connect to AWS EC2 instance on Mac?

In the AWS EC2 Management Console, click on Instances in the left menu (1) under EC2 Dashboard. Click on the Connect button (2) to open the Connect To Your Instance window. You will copy and paste information from this window to your Mac Terminal window later.

Why can I not SSH into my EC2 instance?

This error occurs if you created a password for your key file, but haven't manually entered the password. To resolve this error, enter the password or use ssh-agent to load the key automatically. There are a number of reasons why you might get an SSH error, like Resource temporarily unavailable.


1 Answers

Two possibilities I can think of, although they are both mentioned in the link you referenced:

  1. You're not specifying the correct SSH keypair file or user name in the ssh command you're using to log into the server:

    ssh -i [full path to keypair file] root@[EC2 instance hostname or IP address]

  2. You don't have the correct permissions on the keypair file; you should use

    chmod 600 [keypair file]

to ensure that only you can read or write the file.

Try using the -v option with ssh to get more info on where exactly it's failing, and post back here if you''d like more help.

[Update]: OK, so this is what you should have seen if everything was set up properly:

debug1: Authentications that can continue: publickey,gssapi-with-mic debug1: Next authentication method: publickey debug1: Trying private key: ec2-keypair debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). 

Are you running the ssh command from the directory containing the ec2-keypair file ? If so, try specifying -i ./ec2-keypair just to eliminate path problems. Also check "ls -l [full path to ec2-keypair]" file and make sure the permissions are 600 (displayed as rw-------). If none of that works, I'd suspect the contents of the keypair file, so try recreating it using the steps in your link.

like image 69
gareth_bowles Avatar answered Oct 17 '22 06:10

gareth_bowles