One of my ec2 instance "patched-server-1" was running of kernel version 4.18.0-240.1.1.el8_3.x86_64 and then I did patched the server and current kernel version is 4.18.0-425.19.2.el8_7.x86_64 and I can ssh to the server , then I created an AMI from "patched -server-1" and launched new ec2 instance "patched-server-2" , I cant ssh to it. It give connection refused error.
Reason:
Missing below file under /etc/ssh. These files are missing when I create ec2 instance with the image of upgraded kernel which fails the sshd service start, if I create instance from old kernel only then there is no issue.
MISSSING FILES
==============
-rw-r--r-- 1 root root 82 May 2 17:30 ssh_host_ed25519_key.pub
-rw-r----- 1 root ssh_keys 387 May 2 17:30 ssh_host_ed25519_key
-rw-r--r-- 1 root root 162 May 2 17:30 ssh_host_ecdsa_key.pub
-rw-r----- 1 root ssh_keys 492 May 2 17:30 ssh_host_ecdsa_key
-rw-r--r-- 1 root root 554 May 2 17:30 ssh_host_rsa_key.pub
-rw-r----- 1 root ssh_keys 2578 May 2 17:30 ssh_host_rsa_key
ERROR
======
OpenSSH_9.0p1, LibreSSL 3.3.6
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/sharaddubey/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/sharaddubey/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to ec2-3-6-40-188.ap-south-1.compute.amazonaws.com port 22.
ssh: connect to host ec2-3-6-40-188.ap-south-1.compute.amazonaws.com port 22: Connection refused