【问题标题】:just "permission denied" error if connecting aws server with the use of pem file如果使用 pem 文件连接 aws 服务器,则只是“权限被拒绝”错误
【发布时间】:2016-04-11 14:50:16
【问题描述】:

我可以完全访问 aws。我想使用 .pem 文件示例连接我的服务器,如下所示:

  ssh -i mypemfile.pem ubuntu@ec2-##-##-##-###.eu-west-1.compute.amazonaws.com

现在的问题是我可以完全访问亚马逊控制台,但我没有 .pem 文件。 我通过创建新的密钥对生成了新的 pem 文件,但它不起作用。

我的错误代码如下:

D:\xampp\htdocs\mypic>ssh -vvv -i mypic.pem ubuntu@ec2-52-
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug2: ssh_connect: needpriv 0
debug1: Connecting to ec2-52-31-180-207.eu-west-1.compute.am
debug1: Connection established.
debug3: Not a RSA1 key file mypic.pem.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file mypic.pem type -1
debug1: Remote protocol version 2.0, remote software version
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp2
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,
debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha
4@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-5
debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha
4@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-5
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 133/256
debug2: bits set: 508/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /c/Users/Admin/AppD
debug3: check_host_in_hostfile: match line 3
debug3: check_host_in_hostfile: filename /c/Users/Admin/AppD
debug3: check_host_in_hostfile: match line 4
debug1: Host 'ec2-52-31-180-207.eu-west-1.compute.amazonaws.
debug1: Found key in /c/Users/Admin/AppData/Roaming/npm/.ssh
debug2: bits set: 501/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: mypic.pem (0x0)
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: mypic.pem
debug1: read PEM private key done: type RSA
debug3: sign_and_send_pubkey
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

D:\xampp\htdocs\mypic>

请帮助如何连接 aws 控制台。

对不起,如果我的语言不正确。

提前致谢。

【问题讨论】:

  • 能否贴出 pem 文件的前几行(不是所有行)和最后一行。我怀疑你的 pem 文件格式不正确。
  • @helloV:是的,请查看以下网址:link

标签: php amazon-web-services amazon-ec2 ubuntu-14.04


【解决方案1】:

您必须在字符串中指定.pem 文件的路径

ssh -i "mypemfile.pem" ubuntu@ec2-##-##-##-###.eu-west-1.compute.amazonaws.com

【讨论】:

  • 已经完成了。 OP声明在问题和日志中显示ssh -vvv -i mypic.pem ubuntu@ec2-52-
  • pem 文件的路径用引号括起来,OP 自己的不是,用引号括起来对我有用,不过几个小时前才用引号连接起来
  • 除非文件名中有空格,否则没有区别。
  • 我已经生成了现有实例的新 .pem 文件。会不会造成问题?
  • 可能是因为有一个地方您可以检查附加到您的实例的密钥,请确保它是您生成的新密钥
【解决方案2】:

您的 SSH 密钥可能格式错误。 OpenSSH 使用单行密钥。 您需要使用 -i 和 -m 选项生成新密钥。

第二个选项是您的 pem 密钥没有只读访问权限。如果您尝试使用 pem 键连接,则您无法连接到实例。

试试这个

chmod 400 xxx.pem

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-17
    • 1970-01-01
    • 1970-01-01
    • 2015-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多