LoginSignup
28
15

More than 3 years have passed since last update.

EC2にSSHコマンドで接続した際、Permission denied (publickey,gssapi-keyex,gssapi-with-mic).が出た場合

Posted at

AWS学習中、上記エラーにぶつかったので備忘のために残す。

ssh -i ***.pem ec2-user@IPアドレス

このコマンドを入力すると、

Warning: Identity file ***.pem not accessible: No such file or directory.
ec2-user@IPアドレス: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

このエラー。

EC2へのSSH接続でPermission denied (publickey). が出たときを参照し、コマンド入力するも同様のエラーが続く。

試行錯誤していると、***.pemへのパスが間違っていることに気づく・・・。

ssh -i Desktop/***.pem ec2-user@IPアドレス

これで無事解決!

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'Desktop/***.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 "Desktop/***.pem": bad permissions
ec2-user@IPアドレス: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

・・・と思いきや、今度はこのメッセージに遭遇。

『Amazon Web Services 基礎からのネットワーク&サーバー構築』 によると、これは、

鍵ファイルのパーミッションが他のユーザーにも閲覧できる状態になっているのが理由です。

とのこと。

$ chmod 400 Desktop/***.pem

このコマンドを実行することで、自分だけしか読み込めないようにすることで、突破できました。

28
15
1

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
28
15