Connecting to your AWS Instance with SSH

POSTED ON June 21st, 2017 in:
By clckwrk

If you’re using our AMIs from the Amazon Marketplace you might need some guidance on connecting using SSH. We’ve put together the steps below as a guide to help:

How to SSH using Mac/Linux

1. In a command-line shell, change directories to the location of the private key file that you created when you launched the instance

2. Use the chmod command to make sure that your private key file isn’t publicly viewable. For example, if the name of your private key file is my-key-pair.pem, use the following command:

chmod 400 /path/my-key-pair.pem

3. Use the ssh command to connect to the instance. You specify the private key (.pem) file and user_name@public_dns_name. For Amazon Linux, the username is clckwrk

ssh -i /path/my-key-pair.pem clckwrk@IPv4 Public IP
You see a response like the following. Enter ‘yes’ to complete your SSH connection
The authenticity of host ‘ec2-198-51-100-1.compute-1.amazonaws.com (10.254.142.33)’
can’t be established.
RSA key fingerprint is 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f.
Are you sure you want to continue connecting (yes/no)?

How to SSH using Windows

Prerequisites

Before you connect to your Linux instance using PuTTY, complete the following prerequisites:
·      Install PuTTY
Download and install PuTTY from the PuTTY download page. If you already have an older version of PuTTY installed, we recommend that you download the latest version. Be sure to install the entire suite
·       Locate the Private Key
Get the fully qualified path to the location on your computer of the .pem file for the key pair that you specified when you launched the instance

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
1.     Start PuTTYgen (for example, from the Start menu, choose All Programs > PuTTY > PuTTYgen)
2.     Under Type of key to generate, choose RSA
If you’re using an older version of PuTTYgen, choose SSH-2 RSA
3.     Choose 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
4.     Select your .pem file for the key pair that you specified when you launch your instance, and then choose Open. Choose OK to dismiss the confirmation dialog box
5.     Choose 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. Choose 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.
6.     Specify the same name for the key that you used for the key pair (for example, my-key-pair). 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.

Starting a PuTTY Session

Use the following procedure to connect to your Linux instance using PuTTY. You need the .ppk file that you created for your private key. If you receive an error while attempting to connect to your instance, see Troubleshooting Connecting to Your Instance.
To start a PuTTY session

 

  1. Start PuTTY (from the Start menu, choose All Programs > PuTTY > PuTTY)
  2. In the Host Name box, enter clckwrk@IPv4 Public IP. Be sure to specify the appropriate user name for your AMI
  3. (IPv6 only) To connect using your instance’s IPv6 address, enter clckwrk @ipv6_address. Be sure to specify the appropriate user name for your AMI. For example, under Connection type, select SSH. Ensure that Port is 22. In the Category pane, select Session and complete the following fields:
4. In the Category pane, expand Connection, expand SSH, and then select Auth. Complete the following:
  • Choose Browse
  • Select the .ppk file that you generated for your key pair, and then choose 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 choose Save
  • Choose Open to start the PuTTY session
5. 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
6. Choose Yes. A window opens and you are connected to your instance

List of useful links and guides

·      Using Putty (Windows) to SSH: https://www.youtube.com/watch?v=8Dsq4MeVh8M
·      Using Terminal (Linux) to SSH: https://www.youtube.com/watch?v=K-IRgEge6jA

SaveSaveSaveSave

 
  • footer-client
  • footer-client
  • footer-client
  • footer-client
Web Design by Appnova