macos - 无法在优胜美地机器上使用 pem key 连接到 ec2 实例

标签 macos amazon-web-services ssh amazon-ec2 osx-yosemite

因此,我正在设置两个新的 mac (yosemite) 用于 ssh-ing 到 EC2 实例中,并且有同样的问题。

当我将 .pem key 从 amazon 复制并粘贴到 .ssh/文件夹中时,然后尝试使用以下命令进行 ssh:

sudo ssh -i /users/me/.ssh/key_pair_1_8_5_2015.pem ubuntu@54.186.XXX.XX

我得到以下信息:
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: /users/colin/.ssh/key_pair_1_8_5_2015.pem
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Saving password to keychain failed
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: No more authentication methods to try.
Permission denied (publickey).

这会导致一个弹出框询问
enter you password for the key pair "key_pair..."

当然,您没有 pem key 的 key 对,而且我之前当然没有设置过,所以这没有任何意义。从阅读周围来看,这似乎是一大堆问题的默认错误。

我知道我的权限设置正确,并且我知道我尝试连接的用户没有问题。

我已经以相同的方式设置了多个其他 mac 并以这种方式连接到许多 ec2 开发服务器。

但由于两台 Mac 都有相同的错误,我怀疑这与阻止这种情况的客户端操作系统有关。它们是刚擦过的 mac,以前几乎没有配置(尽管我确实像往常一样设置了 ssh key ),所以我想知道在继续之前是否还有其他需要配置的东西。

真诚感谢您的帮助。非常感谢。

最佳答案

我对使用 EC2 key 的 yosemite 或 el capitan 没有任何问题。这与操作系统无关,与 openssh 版本有关。

确保您的 AMI 正确,有些人在构建 AMI 并将旧 key 留在上面时遇到问题,导致新 key 无法正常启动。还要确保您的权限实际上是私钥上的 0400 或 0600。

尽管我认为您的 key 已损坏,但基于预感:

debug1: key_parse_private_pem: PEM_read_PrivateKey failed

这似乎更像是 key 保存不正确。

另外:您可能不应该运行 sudo SSH 进入它。

关于macos - 无法在优胜美地机器上使用 pem key 连接到 ec2 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33642578/

相关文章:

linux - 我怎样才能将目录复制到其他地方(也许是临时目录)并确保它与原始目录保持同步?

objective-c - 如何获取给定路径的文件大小?

amazon-web-services - 如何使用 .ebextensions 将应用程序负载均衡器固定响应添加到 AWS Elastic Beanstalk

amazon-web-services - 将堆栈部署到云形成中时出现 AWS 错误 "Exceeded attempts to wait"

ssh - 如何通过 ssh 进入 Google Cloud Shell?

ruby - 每当有人通过 SSH 登录时调用进程

macos - 使用 Cocoa 在 Finder 的上下文菜单中添加一个项目

amazon-web-services - 在具有默认配置的EMR群集模式下会发生什么?

windows - Windows : git@github. com 上的 Git clone 不是 git 命令

c - libcurl (7.19,7) 在 OSX (10.6.8) 上因 _mdns_query_callback 而崩溃