How do I troubleshoot problems connecting to my Amazon EC2 Linux instance using SSH?
Last updated: 2021-04-09
I'm unable to connect to my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance. How do I troubleshoot and resolve this issue?
To troubleshoot the issue, log in to the EC2 instance over SSH with verbose messaging on. Use the output messages from the SSH client to determine the type of issue. Then, follow the troubleshooting steps to resolve the issue.
Troubleshoot the issue
1. Log in to the EC2 instance over SSH with verbose messaging on.
user@localhost:~$ ssh -v -i my_key.pem email@example.com
The preceding example uses my_key.pem for the private key file, and a user name of firstname.lastname@example.org. Substitute your key file and your user name for the example's key file and user name. For more information, see Connect to your Linux instance using SSH.
2. Use the output messages from the SSH client to determine the type of issue. Then, use one of the following troubleshooting steps to resolve the issue.
Error: "Connection timed out" or "Connection refused": For information on resolving this error, see I'm receiving "Connection refused or "Connection timed out" errors when trying to SSH to my EC2 instance. How do I resolve this?
For information on resolving "connection timed out" errors on a virtual private cloud (VPC), see How do I troubleshoot instance connection timeout errors in Amazon VPC?
Error: "Permission denied" or "Authentication failed": For information on resolving this error, see I'm receiving "Permission denied (publickey)" or "Authentication failed, permission denied" errors when trying to access my EC2 instance. How do I resolve this?
Error: "Server refused our key": For more information on resolving this error, see How can I log into my Amazon EC2 instance if I receive an error that the server refused our key?
Error: "imported-openssh-key" or "Putty Fatal Error": For more information on resolving these errors, see Why am I receiving "imported-openssh-key" or "Putty Fatal Error" errors when connecting to my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance?
Error: "Enter passphrase for key 'my_key.pem'":
This error occurs if you've created a password for your key file, but haven't manually entered the password. To correct this error, enter the password or use ssh-agent to load the key automatically.
Automatically troubleshoot SSH errors
Some SSH errors, such as Resource temporarily unavailable, can be caused by a variety of issues. To resolve these types of errors, or if you aren't receiving a specific error message, run the AWSSupport-TroubleshootSSH Automation document to automatically find and correct issues. For more information, see I'm receiving errors when trying to connect to my EC2 instance using SSH. How can I use the AWSSupport-TroubleshootSSH automation workflow to troubleshoot SSH connection issues?