【问题标题】:EC2 + ssh: Permission denied (publickey)EC2 + ssh:权限被拒绝(公钥)
【发布时间】:2014-07-12 05:37:21
【问题描述】:

我第一次在 AWS 上打开了一个新的 EC2 实例。但是我无法通过 SSH 访问它,因为它给了我Permission denied (publickey)

也许是因为我没有对new.pem 文件做任何事情??我应该如何处理我的new.pem 文件?

Nets-Mac-Pro:Downloads emai$ ssh -v -i new.pem 12.12.12.123
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to 12.12.12.123 [12.12.12.123] port 22.
debug1: Connection established.
debug1: identity file new.pem type -1
debug1: identity file new.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 18:0a:02:e7:75:25:7e:78:27:a2:c8:ec:0a:e0:c0:a8
debug1: Host '12.12.12.123' is known and matches the RSA host key.
debug1: Found key in /Users/emai/.ssh/known_hosts:77
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: new.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

这是一个全新的服务器,具有新生成的私钥。如果您需要更多信息,请告诉我。

==更新==

Nets-Mac-Pro:Downloads emai$ ssh -i new.pem emai@54.88.57.225
Permission denied (publickey).

【问题讨论】:

  • 您需要使用user@IP-l user 语法为连接指定用户名
  • 用户是指我的 IAM 用户吗?我更新了底部的问题
  • 否,登录新 EC2 实例的用户名。正如 Harry 建议的那样,亚马逊默认为 ec2-user
  • 干得好!!那么现在我可以直接从控制台创建用户吗?我以为我刚刚创建的 IAM 用户组 + 用户会出现(虽然我在创建实例后确实做到了)?

标签: amazon-ec2


【解决方案1】:

假设它是 Amazon Linux 发行版,尝试 ssh -i new.pem ec2-user@your-ip。

【讨论】:

  • 嘿哈利我更新了我的问题尝试你的方法..没用
  • @Edmund 尝试使用 ec2-user,而不是您登录计算机时使用的 your 用户名,而是使用创建 Amazon AMImage 的人的用户名,通常是 ec2-user
  • 您的根密钥 (new.pem) 引用了 ec2 用户。所以你需要使用 ssh -i new.pem ec2-user@
猜你喜欢
  • 2018-02-04
  • 2014-07-24
  • 1970-01-01
  • 2013-05-30
  • 2016-09-19
  • 1970-01-01
  • 2019-11-24
  • 2014-11-08
  • 2019-03-11
相关资源
最近更新 更多