Permission Denied (Public Key) EC2 - amazon-web-services

I'd like to ask you for assistance on this. It is the first time I'm trying
to ssh into EC2 instance from my laptop. I've got pem file with permission bits set to 400 in ~/.ssh
The instance is up and running and my attempt is:
ssh -i ~/.ssh/app-prod.pem coding_hedgehog#ec2-1-7-6-51.eu-west-2.compute.amazonaws.com
output:
coding_hedgehog#ec2-1-7-6-51.eu-west-2.compute.amazonaws.com: Permission denied (publickey)
I'm following this article but nothing seems to work in my case. coding_hedgehog is my IAM and it is displayed when I'm logged into AWS console so the problem can't be using wrong IAM nick.
The EC2 instance runs Ubuntu 20.04
Some tutorials show that using ubuntu#public_dns will work. I get the same error though.
Security Group inbound rules:
Instructions to connect via ssh:

Related

Unable to access instance Permission denied (publickey) after installing vsftpd

I am unable to access my ec2 ssh , the last thing i am sure that i've did is created AMI in aws console and then installed vsftpd:-
sudo apt install vsftpd
That's it.
Now when i am trying to access ec2 ssh i get the following error:-
ssh -i sshkey.pem ubuntu#ec2-00-000-000-000.eu-west-3.compute.amazonaws.com
ubuntu#ec2-00-000-000-000.eu-west-3.compute.amazonaws.com: Permission denied (publickey).
How can i fix this?
Installing vsftpd can never have an impact on your SSH access.
the only things I think of:
you regenerated ssh keys for ubuntu user.
you rebooted your ec2 server and with elatic IP attached and now it has a different IP.
your ssh key has wrong permissions, it should be 600

Default username for ec2 instance spawned by elastic beanstalk

I'm trying to use elastic beanstalk to deploy an application and one of the things I need to do is be able to log into the underlying ec2 instance and add dependencies. I added a key pair to the instance and put the private key file in ~/.ssh on my computer. Next I specified the key pair for the ec2 instance and it restarted and eventually the status was green
When I try to ssh into the ec2 instance I get the following error:
$ ssh ec2-user#myinstance.us-east-1.elasticbeanstalk.com
ec2-user#myinstance.us-east-1.elasticbeanstalk.com: Permission denied (publickey).
In the docs is says this could be due to an incorrect username.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html
Does anyone know what the default username is for ec2 instances created by elastic beanstalk?
Also if I'm doing this all wrong would appreciate some pointers there too.
1.To make sure that the there's no mistake the way you connect:
Go to EC2-> Instances
Select your instance
And press Connect
You should get the command to connect from the instructions from the Connect Popup. The correct username is mentioned there plus instructiins on how to set the correct permissions on the pem (applies to linux)
2.
Make sure that you modified the security group of the instance you're trying to connect do that it allows ssh from the ip of your pc. (This is not the case for the question, since the error is Permission denied (publickey), it means that it's not an sg issue, thx #diego)
3.
Also if you connect from a corporate network, try connecting from another network. It might be firewall issue.
4.
Last but not least make sure you ssh inside the .ssh path, or provide the correct pem path

Unable to connect to AWS EC2 instance (Permission denied publickey)

I am trying to connect to an EC2 instance which I recently spun up via the following SSH command from my Mac OS:
ssh -v -i ~/.ssh/mykey.pem ec2-***.us-east-2.compute.amazonaws.com
I have removed the exact DNS name as it is probably not relevant here. Before I attempted to connect, I took the following steps:
Added a rule for inbound SSH traffic (using my IP)
Created an SSH key in AWS before spinning up the instance
Placed the private key mykey.pem file in my user .ssh folder
I have read many SO questions and other documentation, which is why I was even able to put the above steps together. I am at a loss as to why I can't connect to my EC2 instance, but I am hoping someone will see a flaw in what I am doing here.
You are missing the user name:
ssh -i ~/.ssh/key.pem ec2-user#host-or-ip
Depending on the type of instance, that user name may be ec2-user (amazon linux) or ubuntu (ubuntu). Other versions may have different requirements (some older redhat instances still use root, for example), but that should cover most cases.

AWS ssh into instance giving Permission denied (publicly)

I am trying to ssh into a new EC2 instance. I have followed the instructions and when I attempt to ssh I get Permission denied (publickey).
Below is an image of everything I did in the console according to the instructions. Everything seems to go accordingly until I enter yes. Then it fails. I have followed the instructions twice and get the same result. I also do not have AWS CLI Tools as I believe they are optional.
ssh will use your local username to connect to the instance by default, if you not specified Host, User and IdentityFile in your ~/.ssh/config.
As you call ssh to your instance with the pem specified on the command line you also have to specify the remote user name (which is ec2-user for AWS linux instances and ubuntu for AWS Ubuntu instances).
Try to use this commandline:
ssh -i sub_api.pem ec2-user#ec2-54....

AWS OpsWorks SSH Connect directly permission denied (publickey)

From AWS OpsWorks SSH instructions, connect directly section (ssh from Terminal):
Directly connect to the instance using your terminal application.
ssh://foobar#1.2.3.4
I just copied the ssh url and tried but got permission denied:
> ssh ssh://foobar#1.2.3.4
Permission denied (publickey).
Why?
Do not need to specify the protocol, just do:
ssh foobar#1.2.3.4