为了在 AWS OpsWorks 上部署 Rails 应用程序的实例,我必须为该实例定义一个 SSH 密钥。我按照帮助页面提供的步骤进行操作:http://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-ssh.html#workinginstances-ssh-third
1. 创建了密钥对并下载了 .pem 文件:AWSRails.pem。
2. 更改了文件的 chmod 为 600。
3. 在堆栈页面中,将默认 SSH 密钥添加到先前创建的密钥中(步骤 1)。
4. 在 Instance 页面中,获取公共 DNS 名称:ec2-54-72-154-78.eu-west-1.compute.amazonaws.com。
5. 在同一页面上,获取操作系统:Amazon Linux。
6. 在终端中,尝试建立与实例的 ssh 连接:
ssh -v -i ~/Downloads/AWSRails.pem ec2-user@ec2-54-72-154-78.eu-west-1.compute.amazonaws.com。
我得到了以下输出:
我得到了以下输出:
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: /etc/ssh_config line 102: Applying options for *
debug1: Connecting to ec2-54-72-154-78.eu-west-1.compute.amazonaws.com [54.72.154.78] port 22.
debug1: Connection established.
debug1: identity file AWSRails.pem type -1
debug1: identity file AWSRails.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 f0:52:63:a5:cf:d9:62:bc:f7:b9:f9:04:a7:05:93:5e
debug1: Host 'ec2-54-72-154-78.eu-west-1.compute.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /Users/Hassen/.ssh/known_hosts:12
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: Offering RSA public key: /Users/Hassen/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: AWSRails.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).
阅读调试消息,连接已建立,一切都正常,直到公钥身份验证方法。 我尝试了在StackOverflow上找到的许多相同问题,但都没有解决。
您有任何想法吗?谢谢。
Permission denied (publickey)
。但是我可以通过SSH访问远程AWS实例。 - Hassen