LoginSignup
5
1

More than 1 year has passed since last update.

Permissions 0644 for 'sample_rsa' are too open. 解決方法

Posted at

初めに

dockerコンテナの./sshディレクトリからEC2にsshキーで接続しようとしたら下記のようなエラーが発生。

root@???:~/.ssh# ssh -i "sample_rsa" ec2-user@ec2-??-??-??-??.ap-northeast-1.compute.amazonaws.com

The authenticity of host 'ec2-??-??-??-??.ap-northeast-1.compute.amazonaws.com (??.??.??.??)' can't be established.
ECDSA key fingerprint is SHA???????????????.
Are you sure you want to continue connecting (yes/no)? yes   

Warning: Permanently added 'ec2-??-??-??-??.ap-northeast-1.compute.amazonaws.com,??.??.??.??' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'sample_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "sample_rsa": bad permissions
ec2-user@ec2-??-??-??-??.ap-northeast-1.compute.amazonaws.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

エラー

どうやらこのエラーは、秘密鍵のパーミッションが644になってて他のユーザーからアクセスできるような権限では使えないよ!と指摘してるようです。

Permissions 0644 for 'sample_rsa' are too open.

解決

以下のようにパーミッションを変更してあげれば解決できます。
ちなみに600は、所有者のみ読み書き可能という権限設定になります。

~/.ssh# chmod 600 sample_rsa

これで再度EC2に接続で成功!

参考記事

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1