Amazon Web Services (AWS) provides powerful cloud computing resources, including Linux-based virtual servers known as Amazon EC2 instances. To manage and interact with these instances, you need a way to connect to them. If you're a Windows user, one of the most popular tools for this task is PuTTY. In this guide, we'll walk you through the steps to connect to your Linux instance using PuTTY.
What is PuTTY?
PuTTY is a free and open-source terminal emulator, serial console, and network file transfer application. It supports SSH, which is a secure method of connecting to a remote server. For our purposes, we'll focus on its SSH capabilities.
Prerequisites:
PuTTY: Download both PuTTY and PuTTYgen from its official website.
Putty: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
PuttyGen: https://www.puttygen.com/#Download_PuTTYgen_on_Windows
PEM Key: If you've created a Linux instance on AWS, you should have a
.pem
private key file. (Refer to my previous blog to launch an EC2 instance and also has guide to creating a new key pair: https://kshitijaa.hashnode.dev/user-data-in-aws ) You'll need this file to authenticate and connect to your instance.
Launch as EC2 Instance using Keypair - MyKeyPair to connect using SSH.
Step-by-Step Guide:
1. Convert PEM to PPK:
AWS provides the private key in PEM format, but PuTTY prefers PPK (PuTTY Private Key). Here's how to convert it:
a. Open PuTTYgen
(which you downloaded along with PuTTY).
b. Click on Load
and select the .pem
file that you've saved from AWS.
Make sure that you are loading Private key in PuttyGen, Click on Open to continue.
c. Once loaded successfully, click on Save private key
. A warning about saving the key without a passphrase will pop up. It’s your choice to use a passphrase, but for this tutorial, we're skipping it.
d. Save the file with a .ppk
extension.
I always make a habit of saving this private key as "KeyPairName_Private" as shown below.
2. Connect using PuTTY:
a. Open PuTTY
.
b. In the Host Name (or IP address)
field, input your Linux instance's public DNS or IP address. If you’re using an AWS EC2 instance, you can find this in the EC2 dashboard under the Instances
section.
c. On the left sidebar, navigate to Connection
→ SSH
→ Auth
.
d. Here, click on Browse
and select the .ppk
file you generated in the previous step.
e. Go back to the Session
section on the left sidebar, give this session a name under Saved Sessions
, and click Save
. This step is optional, but it allows you to save these settings for future connections.
f. Click on Open
at the bottom to initiate the connection.
g. The first time you connect, you'll get a security alert. This is PuTTY asking if you trust this host. Click Yes
.
h. You'll be prompted for a username. For AWS EC2 instances, the default username is typically ubuntu
. For other Linux distributions, it might be root
or another username, depending on the setup.
Congratulations, you're now connected to your Linux instance!
Tips and Tricks:
Always keep your private key (both PEM and PPK) secure and never share them. Anyone with access to these keys can connect to your instance.
Regularly update PuTTY to the latest version to ensure you have the latest security patches.
If you have multiple instances or servers, using the
Saved Sessions
feature in PuTTY can save you a lot of time.
Conclusion
PuTTY is an invaluable tool for Windows users needing SSH access to Linux servers. Whether you're managing a personal project, diving into cloud computing on AWS, or administering a fleet of Linux servers, knowing how to use PuTTY efficiently will undoubtedly come in handy. Happy SSH-ing!