Last updated on September 21st, 2021 at 10:41 am
Here’s how you can connect to Amazon EC2 Linux instance from Windows laptop using PuTTy:
Step 1: Create amazon ec2 instance with a new key pair
Step 2: Save your private key to a known location (it’s a .pem file you’ll download in the process)
Step 3: In the EC2 dashboard go the the security group settings for the instance and open ssh port 22
Step 4: Download and install PuTTY.exe from the PuTTY download page.
Step 5: Converting Your Private Key Using PuTTYgen
PuTTY does not natively support the private key format (.pem) generated by Amazon EC2. PuTTY has a tool named PuTTYgen, which can convert keys to the required PuTTY format (.ppk). You must convert your private key into this format (.ppk) before attempting to connect to your instance using PuTTY.
To convert your private key
- Start PuTTYgen (for example, from the Start menu, click All Programs > PuTTY > PuTTYgen).
- Under Type of key to generate, select SSH-2 RSA.
- Click Load. By default, PuTTYgen displays only files with the extension .ppk. To locate your .pem file, select the option to display files of all types.
- Select your .pem file and click Open. Click OK to dismiss the confirmation dialog box.
- Click Save private key to save the key in the format that PuTTY can use. PuTTYgen displays a warning about saving the key without a passphrase. Click Yes. Note A passphrase on a private key is an extra layer of protection, so even if your private key is discovered, it can’t be used without the passphrase. The downside to using a passphrase is that it makes automation harder because human intervention is needed to log on to an instance, or copy files to an instance.
- Specify the same name for the key that you used for the key pair (for example, private_key). PuTTY automatically adds the .ppk file extension.
Your private key is now in the correct format for use with PuTTY. You can now connect to your instance using PuTTY’s SSH client.Step 6: Start a PuTTY session
- Start PuTTY (from the Start menu, click All Programs > PuTTY > PuTTY).
- In the Category pane, select Session and complete the following fields:
- In the Host Name box, enter user_name@public_dns_name. Be sure to specify the appropriate user name for your AMI. For example:
- For an Amazon Linux AMI, the user name is ec2-user.
- For a RHEL5 AMI, the user name is often root but might be ec2-user.
- For an Ubuntu AMI, the user name is ubuntu.
- Otherwise, check with your AMI provider.
- Under Connection type, select SSH.
- Ensure that Port is 22.
- In the Host Name box, enter user_name@public_dns_name. Be sure to specify the appropriate user name for your AMI. For example:
- In the Category pane, expand Connection, expand SSH, and then select Auth. Complete the following:
- Click Browse.
- Select the .ppk file that you generated for your key pair, and then click Open.
- (Optional) If you plan to start this session again later, you can save the session information for future use. Select Session in the Category tree, enter a name for the session in Saved Sessions, and then click Save.
- Click Open to start the PuTTY session.
- If this is the first time you have connected to this instance, PuTTY displays a security alert dialog box that asks whether you trust the host you are connecting to.
- Click Yes. A window opens and you are connected to your instance. Note If you specified a passphrase when you converted your private key to PuTTY’s format, you must provide that passphrase when you log in to the instance.
Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.