How to access EC2 instances on OSX using Terminal

It took me a few minutes to find this information so I am documenting here how to accomplish this:

  1. Download the .pem file.
  2. Place it in a folder and note where you stored it.
  3. Open Terminal.
  4. using cd go to the folder where your .pem file is stored.  EX. cd /Home/User/Desktop
  5. Amazon requires that the private key privileges be set to 400.
  6. Using chmod set the privileges for 400. EX. chmod 400 test.pem
  7. To access using SSH type: ssh -i test.pem ubuntu@amazondnsnamecompute.amazonaws.com
  8. Type in: Yes
  9. That’s it!

Note: You can make simplify frequent connections by placing this in a .sh script.

  • Create a text file.
  • Paste your original command: ssh -i /Home/User/Desktop/test.pem username@amazondnsnamecompute.amazonaws.com
  • Save the text file with the extention .sh
  • Now you can go to the directory with .sh and type: bash filename.sh
How to access EC2 instances on OSX using Terminal