This time, we’ll ssh connect to an instance created on EC2 from a local Machine.
Go to Part 1 for creating a instance on EC2.
- Download a “pem” file that you can download when you create an instance on EC2. (In this tutorial, we downloaded it to “Download” folder)
- You wanna copy this pem file to ~/.ssh folder, but this is just an optional. To do so, open a terminal on Mac, and type
cd ~/.ssh cp ~/Download/downloaded-from-EC2.pem any-name.pem
From here, we'll use the copied pem file (ex. development.pem)
- Go to EC2 site, and check IP address of the instance that you created on Part 1.
- Now you should be able to access to the EC2 server. As an example, if you haveIP address on EC2 : 50.123.456.7
Pem File: development.pem
ssh -i development.pem firstname.lastname@example.org
As we chose Ubuntu as an Operating System, the default root user is “ubuntu”. This might change depending on Operating System.
- Congrats! Now you should be in the EC2 Instance.
- For later use, you can modify ~/.ssh/config so that you can make ssh connections easier.
cd ~/.ssh sudo vi config # enter password
and write something like
Host dev HostName50.123.456.7 IdentityFile ~/.ssh/development.pem User ubuntu
Now, you can ssh access by typing