0 votes
1 view
in AWS by (8.9k points)

This seems to be a common problem but my specific case seems a little different.

I set up a new Amazon EC2 instance using the command line tools and connected via SSH and did some configuration work.

Initially, though, I couldn't ssh on to the instance, I had to stop and restart the instance, then i could connect. Before restarting I just got the response.

Permission denied (publickey)

That was last night, this morning I go back to the same instance and now all I get is

Permission denied (publickey)

I've tried rebooting the instance with no joy.

Can anyone point me in the right direction here? The same command that worked last night no longer works, I'm connecting from my Macbook Pro.

1 Answer

0 votes
by (18.5k points)

Try the following command:

ssh -i ~/.ssh/[keypair name] [email protected][ec2 instance ip]

This should get you in. Remember to use the login user name according to the OS in your instance. 

For Ubuntu-based machines use: ubuntu

For Debian: admin

For Centos: centos

For Amazon Linux: ec2-user

For the rest of the machine types, use ec2-user

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...