LoginSignup
9
6

More than 3 years have passed since last update.

Warning: Identity file ChatSpace.pem not accessible: No such file or directory. ec2-user@13.112.68.204: Permission denied (publickey).のエラーの解決例

Posted at

1.エラーの内容

一度シャットダウンして日を置いて下記のコマンドをしようとしたらできませんでした。
エラー文は下記の通り

Neverland:~ kontatomoya$ ssh -i ChatSpace.pem ec2-user@13.112.68.204
#ログインのコマンドを打ちました
Warning: Identity file ChatSpace.pem not accessible: No such file or directory.
ec2-user@13.112.68.204: Permission denied (publickey).
#ログインできないとのこと

2.原因と解決方法

原因はディレクトリを.ssh(pemファイルのある場所)でコマンドしていなかったからでした。
なので下記のコマンドでログインできます

Neverland:~ kontatomoya$ cd .ssh
#ディレクトリを移動
Neverland:.ssh kontatomoya$ ssh -i ChatSpace.pem ec2-user@13.112.68.204
#コマンドを打ち込む

3.このエラーで手が止まる理由

エラーを理解できなかった理由はpemファイルが何者でどういうコマンドか理解していなかったからでした。

まずpemとは「ただのファイル書式が決まった入れ物のことで、証明書、鍵をいくつでも含めることができるものです。つまり、鍵または証明書またはその両方」です。

この説明で理解された方も多いと思いますが'ssh -i ChatSpace.pem ec2-user@13.112.68.204'はec2-user@13.112.68.204のアプリケーションのpemファイルに情報をinsert(挿入)しますよという意味になります。

なのでpemファイルがない場所ではそもそも情報を追加などできませんのでタイトルのようなエラーが出てきます。

コマンドの内容を理解していれば現在のディレクトリが間違っているのだなと気づくことができます。

9
6
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
9
6