Issue
I have created an ec2-intance on AWS. But when im trying to connect to it by using my .pem
file, im getting error message: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
. I have changed the permission to this file by chmod 400 myfile.pm
.
This is the command i use to connect to my instance: ssh -i ec2demo.pem [email protected]
I also searched for the issue on internet, and some people say i need to type chmod 600 myfile.pem
. It still not works. Im using macOS Mojave, and the ssh client integrated. Do i need to install the AWS-CLI to make it works? Or should it work without AWS-CLI? And is it better to use ssh client from homebrew, or?
Thanx for help
Solution
When launching a new Amazon Linux instance on Amazon EC2, the public half of the keypair is copied to:
/users/ec2-user/.ssh/authorized_keys
You can then login to the instance using the private half of the keypair:
ssh -i key.pem [email protected]
(Or, you can use a DNS name instead of an IP address.)
It sounds like you have not logged into this instance yet, so make sure you login as ec2-user
instead of ec2demo
. The name of the instance does not impact the Linux user on the instance.
Answered By - John Rotenstein