Unable to Connect Linux EC2 Instance via PuTTY (OpenSSH) on Windows Machine
In this article, we will discuss the steps to troubleshoot and resolve the issue of being unable to connect to a Linux EC2 instance via PuTTY (OpenSSH) on a Windows machine. The instance is in a public subnet, and an inbound rule attached to the security group allows traffic on port 22.
Prerequisites
- A Windows machine with PuTTY installed
- An AWS account with an EC2 instance running a Linux-based AMI
- An Elastic IP address associated with the EC2 instance
- An Internet Gateway attached to the VPC where the instance is launched
- A security group attached to the instance that allows inbound traffic on port 22
Troubleshooting Steps
Step 1: Check the Security Group Rules
The first step is to check the security group rules associated with the EC2 instance. Ensure that there is an inbound rule that allows traffic on port 22 (SSH) from your Windows machine's IP address. If not, add a new rule with the following configuration:
- Type: SSH
- Protocol: TCP
- Port range: 22
- Source: Your IP address or a specific IP range
Step 2: Check the Elastic IP Address
Verify that the Elastic IP address associated with the EC2 instance is correctly configured and assigned to the instance. To do this, follow these steps:
- Open the Amazon EC2 console.
- In the navigation pane, choose "Elastic IPs".
- Select the Elastic IP address associated with the instance.
- Check the "Association" section to ensure that the Elastic IP address is associated with the correct instance.
Step 3: Check the Network Interface
Verify that the network interface of the EC2 instance is correctly configured. To do this, follow these steps:
- Open the Amazon EC2 console.
- In the navigation pane, choose "Network Interfaces".
- Select the network interface associated with the instance.
- Check the "Description" tab to ensure that the network interface is in the correct subnet and has the correct security group attached.
Step 4: Check the Instance Connection
Verify that the instance is running and can be connected to using the AWS Systems Manager Session Manager. To do this, follow these steps:
- Open the Amazon EC2 console.
- In the navigation pane, choose "Instances".
- Select the instance that you want to connect to.
- Choose "Connect" and then choose "Session Manager".
- If you can connect to the instance using Session Manager, the issue may be with PuTTY or your SSH configuration.
Step 5: Check the PuTTY Configuration
Verify that the PuTTY configuration is correct. To do this, follow these steps:
- Open PuTTY.
- In the "Host Name (or IP address)" field, enter the Elastic IP address associated with the EC2 instance.
- In the "Port" field, enter 22.
- In the "Category" list, expand "Connection" and then choose "SSH".
- In the "Category" list, expand "SSH" and then choose "Auth".
- In the "Private key file for authentication" field, browse and select the private key file generated when launching the instance.
- In the "Category" list, choose "Session".
- In the "Saved Sessions" field, enter a name for the session and then choose "Save".
- Choose "Open" to open the session.
In this article, we have discussed the steps to troubleshoot and resolve the issue of being unable to connect to a Linux EC2 instance via PuTTY (OpenSSH) on a Windows machine. By following these steps, you should be able to connect to your instance and start working with it.
References
- Troubleshooting connecting to your instance
- Elastic IP addresses
- AWS Systems Manager Session Manager
- Connecting to your Linux instance using PuTTY
# Sample SSH configuration file
Host my-ec2-instance
HostName
Port 22
User ec2-user
IdentityFile