无法访问私钥/PEM/AWS

Private key not accessible / PEM / AWS

我正在尝试 运行 AWS/EC2 上的一个程序,但在启动实例时卡住了。

  1. .pem 密钥文件已创建并链接到实例。密钥保存在我的文档中。
  2. 命令"chmod 400 /Users/name_of_user/Documents/AI/AWS/cle/name_of_key.pem"没有报错
  3. 命令"ssh -i "name_of_key.pem" ubuntu@ec2-XX-YY-ZZZ-76.us-west-2.compute.amazonaws.com"报告:

    Warning: Identity file name_of_key.pem not accessible: No such file or directory.
    
  4. 然后说:

The authenticity of host 'ec2-XX-YY-ZZZ-76.us-west2.compute.amazonaws.com (XX.YY.ZZZ.76)' can't be established.ECDSA key fingerprint is SHA256:o6Vv2Doje9CyLv+YxbrlJaDcEGydZTYOmP0l3FBa5ps. Are you sure you want to continue connecting (yes/no)? yes

  1. 反正我说'yes'。然后再次警告

Warning: Identity file name_of_key.pem not accessible: No such file or directory. Permission denied (publickey).

你知道为什么私钥无法访问吗?我应该把它保存在一个特殊的地方吗?

非常感谢

ssh 似乎找不到您的密钥。您应该使用密钥的绝对路径:

ssh -i "/Users/name_of_user/Documents/AI/AWS/cle/name_of_key.pem" ubuntu@ec2-XX-YY-ZZZ-76.us-west-2.compute.amazonaws.com

cd变成/Users/name_of_user/Documents/AI/AWS/cle和运行

ssh -i "name_of_key.pem" ubuntu@ec2-XX-YY-ZZZ-76.us-west-2.compute.amazonaws.com