Introduction
Amazon EC2 allows users to run virtual servers in the cloud. If you have an EC2 instance running and need to access it from your Windows laptop, follow these steps to connect securely.
Index
- Introduction
- Requirements Before You Start
- Step 1: Convert Your .pem Key to .ppk Format
- Step 2: Install PuTTY
- Step 3: Connect to Your EC2 Instance Using PuTTY
- Alternative Method: Using Windows Subsystem for Linux (WSL)
- Troubleshooting Common Issues
- Security Best Practices
- Conclusion
Requirements Before You Start
- An AWS account with an active EC2 instance
- The key pair (.pem file) used when setting up the instance
- Administrator access to your Windows laptop
- The public IP address or DNS name of your EC2 instance
Step 1: Convert Your .pem Key to .ppk Format
Windows requires a different format for SSH connections. Since AWS provides .pem keys, they must be converted to .ppk format using PuTTYgen.
- Download PuTTYgen from the official website
- Open PuTTYgen and load your .pem file
- Click Save private key to store it as a .ppk file
Step 2: Install PuTTY
- Download PuTTY from the official website
- Run the installer and complete the installation
Step 3: Connect to Your EC2 Instance Using PuTTY
- Open PuTTY
- In the Host Name field, enter:
ec2-user@your-instance-public-ip
Replace your-instance-public-ip with the actual IP address. If your instance runs Ubuntu, replace ec2-user with ubuntu.
- In the left sidebar, navigate to Connection > SSH > Auth
- Click Browse, select your .ppk key, and connect
- If prompted with a security alert, click Yes to proceed
Alternative Method: Using Windows Subsystem for Linux (WSL)
Windows Subsystem for Linux (WSL) offers built-in SSH functionality without requiring PuTTY.
- Enable WSL by running this command in PowerShell (Administrator mode):
wsl --install
- Restart your computer
- Open the WSL terminal
- Navigate to the folder containing your .pem key
- Change permissions for security:
chmod 400 your-key.pem
- Connect using SSH:
ssh -i "your-key.pem" ec2-user@your-instance-public-ip
Troubleshooting Common Issues
Connection Timed Out
- Verify that your EC2 instance is running
- Check security group settings (ensure port 22 is open for SSH access)
- Confirm the public IP address is correct
Permission Denied
- Make sure you are using the correct username for your operating system
- Ensure the correct key pair is selected
- Check that the key file permissions are properly set
Server Refused the Key
- Confirm that you are using the correct key pair
- Ensure the key file was properly converted to .ppk format
Security Best Practices
- Use SSH key pairs instead of passwords for authentication
- Regularly rotate key pairs to enhance security
- Restrict SSH access to trusted IP addresses only
- Consider using AWS Systems Manager Session Manager instead of direct SSH for better security
Conclusion
Connecting to an EC2 instance from a Windows laptop is straightforward when using PuTTY or WSL. Once configured, accessing cloud servers securely becomes much easier.
For advanced setups, explore AWS Session Manager or configure SSH settings to simplify access to multiple instances.
Let me know if you need any clarifications or further guidance.
Top comments (1)
Very Clear Explanation, steps are making the things easy to understand