EC2

EC2 Ubuntu 접속 시 "Server refused our key" 에러가 발생할 때

하눤석 2023. 4. 5. 10:24
728x90

서론

 

EC2 Ubuntu를 ubuntu@{public ip주소]로 접속하려는데 Server refused our key메시지와 아래의 에러를 반환했습니다.

Disconnected : No supported authentication methods available (server sent :publickey)

해당 에러의 원인은 매우 다양하다고 합니다. 다양한 원인과 해결방법을 알아보겠습니다..

 

 

 


원인

 

AWS 공식 문서를 참고하여 찾은 대표적인 원인들입니다.

 

1. You're using the incorrect user name for your AMI when connecting to your EC2 instance. The usual user names are ec2-user, ubuntu, centos, root, or admin

 

 올바르지 않은 계정을 사용했을 때 발생할 수 있습니다. 위 설명에 나와있듯 ec2-user, ubuntu, centos, root, admin과 같은 username으로 바꿔 접속하면 됩니다.

 

2. The user trying to access the instance was deleted from the server or the account was locked.

 

삭제됐거나, 잠긴 계정으로 접근했을 때 발생할 수 있습니다. EC2 서버가 정상적으로 동작하는지 확인해보아야 합니다.

 

3. There are permissions issues on the instance or you're missing a directory.

 

로그인하려는 유저가 권한을 갖고 있지 않거나, 잘못된 디렉토리로 접근했을 때 입니다. 

AWS에서는 4가지 해결방법을 제시하고 있습니다.

 

- Use the EC2 Serial Console

- Use AWS Systems Manager Session Manager to log into the instance and check the permissions

- Automatically correct issues causing the error by running the AWSSupport-TroubleshootSSH document

- Use user data to fix permissions on the instance

 

자세한 방법은 아래 링크에 나와있습니다. 

 

 

Resolve "Server Refused Our Key" errors when connecting to EC2 instances | AWS re:Post

I'm receiving the "Server refused our key" error when connecting to my Amazon Elastic Compute Cloud (Amazon EC2) instance using SSH.

repost.aws

 

4. You're using the incorrect private key file when connecting to your EC2 instance. 

 

가장 대표적인 원인입니다. ec2를 생성할 때 발급받는 key pair가 적용되지 않은 것 입니다.

.pem 확장자로 발급받은 key를 사용해야 합니다. putty로 접속할 경우 puttyGen을 사용하여 .pem형식의 key를 .ppk 타입의 key로 변환해서 접속해야 합니다.

 

 

5. SSH server settings in /etc/ssh/sshd_config were changed. 

 

해당 경로에 있는 설정파일을 수정했을 때 발생할 수 있는 에러입니다. 해당 파일을 새로 받아서 추가해주어야 합니다.

아래 링크에 해결방법이 자세히 나와있습니다.

 

Regain access to EC2 instance after editing sshd_config | AWS re:Post

I changed my Amazon Elastic Compute Cloud (Amazon EC2) instance's sshd_config file, and now I can't access my instance using SSH. How can troubleshoot and I resolve this?

repost.aws



6. The operating system couldn't mount (/etc/fstab) home directories

 

fstab 폴더가 마운트되지 않았을 때 나타날 수 있는 문제입니다.  해결책은 아래 링크에 있씁니다.

 

 

Troubleshoot an EC2 Linux instance in emergency mode | AWS re:Post

When I boot my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance, the instance goes into emergency mode and the boot process fails. Then, the instance is inaccessible. How can I fix this?

repost.aws

 

 

참고 : https://repost.aws/knowledge-center/ec2-server-refused-our-key

 

 

 

 

320x100