Check if kes are in SHA-1 or some warrants - if yes then try "update? change keys to RSA . The another advice is if you user PUTTY for SSH connection, followed steps are recommended:
- backup all keys (and on your decision PUTTY confit)
- install (update )putty to the latest stable version
- try to connect, in case of no change disable/enable compression and check connection
Trying to lower key file access privileges may also help mostly if not only you are only user of one stem account.
In my opinion upgrading keys to the latest standard (avoiding MD5 fingerprinting) or changing them to latest version will help. If this is new instance and you can't connect - verify Security Groups for PORT 22 - if port is open limit it to accept only your IP and try to connect. Soft restart of instance may be some solution in scenarios of resources problem.
Not elegant way that helps (USE IT ONLY AT INSTANCES WITHOUT CRITICAL/LIVE SERVICES to avoid data loss, USE OF IT IS JUST EXAMPLE based on own experience where asap action was needed and this fast way helped , in my case it was data breach - it was on ARM IoT device without chance to physical access over the same day) sio "hard reset" allowed our learning emploee diagnoze data breach and secure device with redirect pockets for analyse. On AWS use this only as I advised - DO NOT USE or USE at very last choice ;)
replied 3 years ago
Thank you for your comment. We'll review and update the Knowledge Center article as needed.
I was experiencing this same error message "Connection Timed Out", when I tried to SSH using the SSH Client, at that moment my security group was only permitting inbound traffic via SSH from my local IP, but when I reconfigured it to allow SSH traffic from anywhere (0.0.0.0), the error message cleared and I was able to successfully SSH into the Amazon Linux 2 instance.
I had to use this type of security group configuration, because this was a testing environment, so in a production environment, how does one resolve this error message when using a local IP from my computer?
Thanks
replied 3 years ago
Thank you for your comment. We'll review and update the Knowledge Center article as needed.
Here is the official resolution video from AWS. Please check it out.
How do I fix Connection refused or Connection timed out errors when connecting to an EC2 instance? https://www.youtube.com/watch?v=b1K0CNYxtC0
replied 2 years ago
For Latest Ubuntu
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type:
text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
sed -i "s|PasswordAuthentication no|PasswordAuthentication yes|" /etc/ssh/sshd_config
if [ -d "/etc/ssh/sshd_config.d" ]; then
for file in /etc/ssh/sshd_config.d/*; do
if [ -f "$file" ]; then
sed -i "s|PasswordAuthentication no|PasswordAuthentication yes|" "$file"
fi
done
fi
echo -e 'ubuntu:YourPasswordHere' | chpasswd
systemctl restart sshd
iptables -P INPUT ACCEPT
iptables -F
if [[ $( cat /etc/hosts.[ad]* | grep -vE '^#' | awk 'NF' | wc -l) -ne 0 ]];\
then sudo sed -i '1i sshd2 sshd : ALL: allow' /etc/hosts.allow; fi
--//
replied a year ago
This article was reviewed and updated on 2026-06-17.
Relevant content
asked 3 years ago
asked a year ago

