Amazon EC2 权限被拒绝(公钥) [英] Amazon EC2 Permission denied (publickey)

查看:41
本文介绍了Amazon EC2 权限被拒绝(公钥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个常见问题,但我的具体情况似乎有些不同.

This seems to be a common problem but my specific case seems a little different.

我使用命令行工具设置了一个新的 Amazon EC2 实例并通过 SSH 进行连接,并做了一些配置工作.

I set up a new Amazon EC2 instance using the command line tools and connected via SSH and did some configuration work.

不过,最初我无法通过 ssh 连接到实例,我必须停止并重新启动实例,然后才能连接.在重新启动之前,我刚刚得到了响应.

Initially, though, I couldn't ssh on to the instance, I had to stop and restart the instance, then i could connect. Before restarting I just got the response.

Permission denied (publickey).

那是昨晚,今天早上我回到同一个实例,现在我得到的是

That was last night, this morning I go back to the same instance and now all I get is

Permission denied (publickey).

我试过重启实例,但没有任何乐趣.

I've tried rebooting the instance with no joy.

有人能在这里指出我正确的方向吗?昨晚运行的命令不再起作用,我正在从我的 Macbook Pro 连接.

Can anyone point me in the right direction here? The same command that worked last night no longer works, I'm connecting from my Macbook Pro.

推荐答案

我将回答我自己的问题,以防其他人看到同样的事情......昨晚我已经完成了:

I'm going to answer my own question in case anyone else sees the same thing... Last night i had done:

ssh-add ~/.ssh/[keypair name]

然后一直在联系:

ssh ec2-user@[ec2 instance ip]

今天早上我尝试了同样的方法,但无法连接.但是做

This morning I tried the same and couldn't connect. But doing

ssh -i ~/.ssh/[keypair name] ec2-user@[ec2 instance ip]

让我进去.

在密钥对上使用 ssh-add 再次让我进入.我猜 ssh-add 只在我发出它的 shell 中有效.当我关闭了终端窗口并打开了另一个我不再使用该密钥对而没有明确说明.

Using ssh-add on the key pair again gets me in. I'm guessing ssh-add only works within the shell I'd issued it in. When I closed the terminal window and opened another I no longer had that keypair available without being explicit.

这篇关于Amazon EC2 权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆