How to Connect to AWS from Mac Terminal

by Dave Wilson

Amazon Web Services allows small companies to have a large presence on the Web via instant online access to IT infrastructure resources. The Mac OS X operating system features a powerful command line that you can use to access the Amazon Web Service. Configure the Mac OS X command line terminal to connect and setup your AWS services.

1

Go to the Amazon Web Services page in your Mac's browser and sign in to your account via the secure server option.

2

Click the X.509 certificates link and then click Create New followed by Yes. Click the links displayed to download and save the PEM files.

3

Type the URL for the Amazon EC2 API Tools Web page into the address bar at the top of the Safari browser window and press the Enter key. Click the Download the Amazon EC2 API Tools link and save the file to your computer.

4

Launch Finder, and then click Applications, Utilities and Terminal to open a command line terminal window.

5

Enter cd in the command prompt, and then mkdir .ec2, cd .ec2 followed by open ..

6

Click once on the Safari browser window and then press the Alt key. Click the Window menu item near the top of the browser window and click Downloads in the context menu.

7

Right-click on one of the files listed in the Downloads window that ends with “.pem” and click Show Containing Folder. Enter cp /download_directory_path/*.pem . at the command prompt.

8

Right-click the ec2-api-tools.zip file listed in the Downloads window and click Show Containing Folder. Double-click the ec2-api-tools.zip file to extract the compressed files to the download directory.

9

Enter cp –R cp /download_directory_path/bin at the command line and then enter cp –R cp /download_directory_path/lib.

10

Enter vi ~/.bash_profile on the command line. Use the arrow keys on the keyboard to navigate to the first empty line at the end of the text document.

11

Press the I key on the keyboard. Enter export EC2_HOME=~/.ec2 into the text document. Enter export PATH=$PATH:$EC2_HOME/bin in the text page. Enter export EC2_PRIVATE_KEY=ls $EC2_HOME/pk-*.pem. Enter export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/ into the text document.

12

Press the Esc key and then enter :wq to save changes to the document. Enter source ~/.bash_profile in the command line.

13

Enter ec2-describe-images –o amazon at the command prompt. The command line output displays a list of images which confirm you are now connected to AWS via the Mac terminal.

Items you will need

About the Author

Dave Wilson has been writing technical articles since 1993, including manuals, instructional "how-to" tips and online publications with various websites. Wilson holds a Bachelor of Arts in psychology from the University of California, Los Angeles and has Microsoft, Cisco, and ISC2 (CISSP) technical certifications. He also has experience with a broad range of computer platforms, embedded systems, network appliances and Linux.