# SSH 접속 시 pem키 Bad Permission 오류 해결 방법

작성일자: 2024.01.24

AWS에서 EC2 생성 시 pem Key를 새로 생성한 후 해당 key로 ssh 접속을 시도하면 아래와 같이 오류가 발생한다.

imac@ip-11-222-333-222 Downloads % ssh -i "ops.pem" ubuntu@222.111.222.333
############################################################
##         WARNING: UNPROTECTED PRIVATE KEY FILE!         ##
############################################################
Permissions 0644 for 'ops.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "ops.pem": bad permissions
ubuntu@ip-222-111-222-333: Permission denied (publickey).
imac@ip-11-222-333-222 Downloads %

이럴 때엔 pem Key을 chmod 명령어를 이용하여 수정하면 정상적으로 접속이 가능하다.

$ chmod 400 ./파일명.pem
imac@ip-11-222-333-222 Downloads % chmod 400 ./ops.pem
imac@ip-11-222-333-222 Downloads % ssh -i "ops.pem" ubuntu@ip-222-111-222-333
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 6.2.0-1017-aws x86_64)

* Documentation:  https://help.ubuntu.com
* Management:     https://landscape.canonical.com
* Support:        https://ubuntu.com/advantage

  System information as of Tue Jan 23 05:23:14 UTC 2024

  System load:  0.0               Processes:             103
  Usage of /:   30.9% of 7.57GB   Users logged in:       0
  Memory usage: 26%               IPv4 address for eth0: 222.111.222.333
  Swap usage:   0%

Expanded Security Maintenance for Applications is not enabled.

44 updates can be applied immediately.
26 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

ubuntu@ip-222-111-222-333:~$
	
An unhandled error has occurred. Reload 🗙