Unable to SSH into my EC2 Instance Permission denied (publickey)

0

Hello!

I keep getting Permission denied (publickey) when I attempt to log into my instance.

The key pair was lost for my instance. I created a new (temporary) instance with a new Key Pair and attached it to the volume from the main instance. From here I was was able to connect via ssh and I went through all the steps from this link... h

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#replacing-lost-key-pair

I thought I was set but, I keep getting Permission denied (publickey) when I attempt to log in with the new key. Any help would be greatly appreciated!

My Instance ID is i-076850d43eaaf5ee3

Edited by: RebelGrot on Apr 16, 2019 2:26 PM

질문됨 5년 전2542회 조회
3개 답변
0

Hi RebelGrot,

Generally, as noted in the AWS documentation here [1], 'Permission Denied' error messages when attempting to SSH are commonly caused by either 1) incorrect username, 2) incorrect private key or 3) incorrect OS level permissions.

Since you already attempted to change the private key with no success, I would also recommend reviewing the following permissions (mount point refers to the recovery mount point you attached the volume on your temporary instance):

chmod 755 <mount_point>/home
chmod 700 <mount_point>/home/ec2-user
chmod 700 <mount_point>/home/ec2-user/.ssh
chmod 600 <mount_point>/home/ec2-user/.ssh/authorized_keys

Additionally, I would also recommend reviewing your SSH configuration file <mount_point>/etc/sshd_config.

Thanks.
[1] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#TroubleshootingInstancesConnectingMindTerm

답변함 5년 전
0

Thanks LoiyAWS! I am a bit of a newb when it comes to command line and ssh.

I am going to give these permission changes a try again. I'll check back and let you know how it goes.

Edited by: RebelGrot on Apr 24, 2019 9:30 PM

답변함 5년 전
0

I changed the permissions and still got the result of Permission Denied (publicly). So I created a new key pair and a new recovery instance and went through the process again. This time it worked!

답변함 5년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠