Redhat Amazon Image(AMI) Creation Issues

Continuing with my latest adventures in AWS and Redhat, I found an issue that occurs with a pretty high degree of frequency. The problem occured when I did the following:

  1. Launch an image using the default RHEL image
  2. Configure/install all of the things needed for that instance
  3. Stop instance, create image from it.
  4. Launch instance from newly created image
  5. Try to connect to instance via SSH
  6. Connection refused. Sad face.

Turns out it’s an issue that is present in the image provided by Amazon, and the /etc/ssh/sshd_config is messed durring the image creation/rebooting process.

To fix this, I commented out the following three lines from /etc/rc.d/rc.local file:

1 cat <<EOF>> /etc/ssh/sshd_config 
2 UseDNS no 
3 PermitRootLogin without-password

And the following from /etc/ssh/sshd_config

1 permitrootlogin without-password
2 permitrootlogin without-passwordUseDNS no

Stack overflow - EC2 instance launched from AMI not reachable(ssh) after start/stop or reboot
Redhat Bugzilla Bug #956531