んだ日記

ndaDayoの技術日記です

EC2にssh 接続→ Permissions 0644 for 'hoge.pem' are too open. 

EC2にssh接続しようとしたら

`% ssh -i hoge.pem ec2-user@IPv4 パブリック IP

Warning: Permanently added 'IPv4 パブリック IP ' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'hoge.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 "hoge.pem": bad permissions
ec2-user@52.194.254.233: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
エラーメッセージ

Permissions 0644 for 'hoge.pem' are too open.
権限が大きすぎるよと。。

権限を調べたら、、となっていた。

-rw-r--r--@ 1 user staff  1696  3 29 21:47 hoge.pem
解決する

自分だけが読めるように変更すればOK。

% chmod 400 hoge.pem

忘れそうなのでメモ、

0…「---」
1…「--x」
2…「-w-」
3…「-wx」
4…「r--」
5…「r-x」
6…「rw-」
7…「rwx」