AWS EC2: Connect to Linux Instance using SSH

Connect to Linux Instance using SSH Video
  1. Go to Amazon Web Services’ Website (Link)
Image for post
Image for post

2. Sign in if you have account, if not make one

Image for post
Image for post

3. Press EC2

Image for post
Image for post

4. Press Running Instances. If you don’t have a running instance, please see part 1 of the tutorial.

Image for post
Image for post

5. Select your instance and make sure your key (pem file) matches your key pair name

Image for post
Image for post

6. Use the chmod command (in bold below) to make sure your private key file isn’t publicly viewable. Please see commonly asked questions section below if you have issues and are using windows.

chmod 400 /path_to_key/my_key.pem

7. Finally, SSH to your EC2 instance (in bold below)

ssh -i /path_to_key/my_key.pem user_name@public_dns_name

Commonly Asked Questions/Issues:

  1. What if I don’t know my username?

Answer: Please use the appropriate UserName based on what type of Amazon Machine Image Type you selected in Part 1.

Image for post
Image for post
Usernames for Various Amazon Machine Images

2. If you get the following: “chmod is not recognized as an internal or external command”, you are probably using a Windows machine (it is not normally a windows command).

Potential Fix 1: Download and install Gnu on windows (GOW) from the following link. Basically, GOW allows you to use linux commands on windows (including chmod)

Linux Commands on Windows (GOW)

Potential Fix 2: If you want to Install Git on Windows, it gives you the option to add unix tools (chmod and ssh included).

Concluding Remarks

Please let me know if you have any questions! I am happy to answer questions in the comments section below or on the youtube video page, or through Twitter. The next tutorial is AWS EC2: Install Anaconda on Linux Instance.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store