运行EC2实例突然拒绝SSH连接 [英] Running EC2 instance suddenly refuses SSH connection

查看:543
本文介绍了运行EC2实例突然拒绝SSH连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置EC2实例夫妇几天前,甚至昨晚我能够SSH没有问题。今天早上,我不能ssh。

I've set up the EC2 instance couple days ago and even last night I was able to SSH to it with no problems. Today morning, I can't ssh to it. Port 22 is already open in the security group and I haven't changed anything since last night.

错误:

ssh: connect to host [ip address] port 22: Connection refused


$ b b

我最近有类似的问题,我不知道为什么会发生,所以我不得不创建一个新的实例,重新设置,连接和配置所有的EBS存储到新的。给我几个小时...现在又发生了。在上一个,我安装了 denyhost ,这可能阻止了我,但在当前,只有apache2和mysql运行。

I had similar issue recently and i couldn't figure out why it was happening, so I had to create a new instance, set it up again, and connect and configure all EBS storages to the new one. Took me couple hours... and now it's happening again. In the previous one, I've installed denyhost, which might have blocked me, but in the current one, there are only apache2, and mysql running.

当前实例已经启动了16个小时,所以我不认为是因为它没有完成启动...另外,端口22对所有源(0.0。 0.0 / 0),并且使用tcp协议。

The current instance has been up for 16 hours now, so I don't think it's because it didn't finish booting... Also, port 22 is open to all sources (0.0.0.0/0) and is using tcp protocol.

任何想法?

谢谢。

推荐答案

在@ abhi.gupta200297的帮助下,我们能够解决它。

With the help of @abhi.gupta200297, we were able to resolve it.

问题是 / etc / fstab ,并且sshd应该在 fstab 成功后启动。但是它不是,因此,sshd不会启动,这就是为什么它拒绝连接。解决方案是创建一个临时实例,从原始实例安装根EBS,并从 fstab 注释掉东西,它让我再次连接。对于将来,我只是停止使用 fstab 并创建了一组shell命令来将EBS卷挂载到目录中,并将它们添加到 / etc / init .d / ebs-init-mount 文件,然后运行 update-rc.d ebs-init-mount defaults 来初始化文件, m不再遇到锁定的ssh问题。

The issue was the error in /etc/fstab, and sshd was supposed to be started after fstab is successful. But it wasn't, hence, the sshd wouldn't start and that's why it was refusing the connection. Solution was to create a temporary instance, mount the root EBS from the original instance, and comment out stuff from the fstab and voila, it's letting me connect again. And for the future, I just stopped using fstab and created bunch of shell commands to mount the EBS volumes to directories and added them in /etc/init.d/ebs-init-mount file and then run update-rc.d ebs-init-mount defaults to initialize the file and I'm no longer having issues with locked ssh.

UPDATE 4/23/2015

Amazon小组创建了一个类似问题的视频教程,并介绍了如何使用此方法进行调试: https://www.youtube。 com / watch?v = _P29ZHu_feU

Amazon team created a video tutorial of similar issue and show how to debug using this method: https://www.youtube.com/watch?v=_P29ZHu_feU

这篇关于运行EC2实例突然拒绝SSH连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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