さんざんはまったのでメモ。
何時間か浪費した後、イメージ側のバグだったことが判明orz
EC2 instance launched from AMI not reachable(ssh) after start/stop or reboot - stackoverflow
When we launch an instance from an AMI. At first the instance is accessible(ssh). Once we stop/start the instance or reboot it the machine becomes inaccessible via ssh,we can ping it though. We see below error in System log. AMI ID used - ami-72dc9220 Instance - i-0896a15f -
まさにこれです。
Was able to fix this. This is due to a bug from REDHAT for 6.4 rhel instanceshttps://bugzilla.redhat.com/show_bug.cgi?id=956531. After launching the machine from an AMI. Connect to the machine and switch to root user and make below changes to /etc/rc.d/rc.local file ...
Remove the following three lines and save the file:
cat <> /etc/ssh/sshd_config UseDNS no PermitRootLogin without-password ../ One should also remove garbage entries from /etc/ssh/sshd_config file .. The machine once rebooted after these changes works fine.
Thanks Ashwani
バ、バグ・・・
ということで、RHEL6.4のインスタンスを起動したら、
[root@host ~]# vi /etc/rc.d/rc.local
で、以下の3行を削除
cat <<EOL >> /etc/ssh/sshd_config
UseDNS no
PermitRootLogin without-password
また、/etc/ssh/sshd_config
にゴミが書き出されてたら修正
UseDNS no
PermitRootLogin without-passwordUseDNS no
PermitRootLogin without-password
↓このままだと再起動後sshd_configのエラーでsshdが起動しない・・・修正
UseDNS no
PermitRootLogin without-password
ここまでできたら再起動して、再びインスタンスに接続できることを確認。