【问题标题】:"UNPROTECTED PRIVATE KEY FILE!" Error using SSH into Amazon EC2 Instance (AWS)“未受保护的私钥文件!”使用 SSH 连接到 Amazon EC2 实例 (AWS) 时出错
【发布时间】:2012-01-01 21:17:05
【问题描述】:

对于某些人来说,这可能是一个愚蠢的简单问题:)

我在 Amazon EC2 上创建了一个新的 linux 实例,并在其中下载了 .pem 文件以允许我通过 SSH 登录。

当我尝试 ssh 时:

ssh -i myfile.pem <public dns>

我明白了:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'amazonec2.pem' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: amazonec2.pem
Permission denied (publickey).

this post 之后,我尝试 chmod +600 pem 文件,但现在当我 ssh 时,我得到了:

Permission denied (publickey).

我在这里犯了什么小学生错误? .pem 文件位于我的主文件夹中(在 osx 中)。它的权限如下所示:

-rw-------@   1 mattroberts  staff    1696 19 Nov 11:20 amazonec2.pem

【问题讨论】:

  • 当您使用错误的 pem 文件时也会出现此错误。
  • 还要确保在创建实例后创建实例并选择密钥对作为要使用的指定密钥。我反其道而行之。
  • 我在 Windows 中使用 WinSCP。有nothing to dochmod 400 myfile.pem,因为它使用了PuTTYgen 从pem 文件生成的myfile.ppk

标签: amazon-web-services authentication ssh amazon-ec2 permissions


【解决方案1】:

编辑默认安全组以允许端口 22 的入站 TCP 流量:

【讨论】:

    【解决方案2】:

    您需要对密钥文件 (myfile.pem) 设置一些保守的权限。 尝试将其更改为r--------400

    【讨论】:

      【解决方案3】:

      ssh-rsa

      you end up pasting
      

      sh-rsa

      So before trying other solutions, see **if you've pasted your key correctly**! i.e.
      

      猫~/.ssh/id_rsa.pub

      Only if you're certain, perform the next steps; trying to ssh in a **verbose mode** (i.e. flag `-v`) might point you to the actual issue:
      
      

      ssh -v -i @ -p

      
      CMD 
      CLI     ssh -i YOUR_PEM_FILE.pem ec2-user@YOUR_IP
      

      【讨论】:

        【解决方案4】:

        你不是root然后运行这个命令

        sudo chmod 400 -R myfile.pem
        

        不是root然后运行这个命令

        chmod 400 -R myfile.pem
        

        【讨论】:

          【解决方案5】:

          适用于 Windows 10。

          。右键单击文件 .属性->安全->禁用继承 .now 添加 -> 你的用户(窗口)只有“读取” .点击确定

          现在它为我工作

          【讨论】:

            【解决方案6】:

            解决此问题的方法是将 .pem 文件移动到应用程序目录中。 Soo 说 fooapp 是我的应用程序的名称。我直接把它放在那里。

            【讨论】:

              【解决方案7】:

              您还应该检查您的 .pem 文件是否未损坏。我花了大约一个小时挠头,决定用这条线检查一下

              openssl rsa -check -in test.pem -noout
              

              如果它返回“RSA key ok”,那么你很好。如果没有,请确保您拥有正确的文件,并且无论出于何种原因正确复制它。

              【讨论】:

                【解决方案8】:

                如果您在 Windows 10 上使用 ubuntu 子系统,并且如果您 sudo chmod 将密钥更改为 400,那么它可能仍然会出现“加载密钥 pem:权限被拒绝”错误

                ls -al 你会看到 root 现在拥有该文件! chown 给你的登录用户,然后它就可以工作了。

                【讨论】:

                  猜你喜欢
                  • 2010-09-17
                  • 2012-04-22
                  • 2017-10-15
                  • 2014-11-28
                  • 2018-11-28
                  • 1970-01-01
                  • 2015-06-22
                  • 2013-05-26
                  相关资源
                  最近更新 更多