AWS: Fix WARNING: UNPROTECTED PRIVATE KEY FILE!

I just moved my project to another laptop including “.pem” file for remote ssh to AWS EC2.
Once I’m trying to login to remote ssh, accidentally the authentication prompted security warning like below.

The authenticity of host '5x.xxx.xx.xxx (5x.xxx.xx.xxx)' can't be established.
ECDSA key fingerprint is SHA256:*****************************.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '5x.xxx.xx.xxx' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/adiyatmubarak/.ssh/key.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 "/Users/adiyatmubarak/.ssh/key.pem": bad permissions

I guess because the file permission, and here is my current permission.

-rw-r--r--@  1 adiyatmubarak  staff  1675 Aug  5 13:19 key.pem

The problem solved after I only grant my user on my “.pem” file.

$ chmod 600 key.pem
$ ls -la
$ -rw-------@  1 adiyatmubarak  staff  1675 Aug  5 13:19 key.pem
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s