I've made this as literal and direct as I can. Want to spin up an EC2 instance? Follow these steps to the letter, and unless AWS has changed their settings, you'll be in business. Any corrections or comments are welcome.
Sign In
Navigate to https://aws.amazon.com/
and click Sign In to the Console.
You're now in your AWS Management Console.
Navigate to EC2
EC2 is a service that Amazon provides. From your AWS Management console, use either of these two options to open up the EC2 Dashboard:
1) Select from Recently Visited Services:
or
2) Select from the Services dropdown menu located next to the AWS logo (top-left of the page).
Navigate to Instances
Click either of these buttons to reach the Instances page.
Launch an Instance
Click the bright orange button:
Choose an Image
I chose Amazon Linux 2 AMI (HVM), SSD Volume Type
If you're using Ubuntu (recommended) you only have to adjust one step, which I'll point out below.
Select the Free Tier:
Click that blue button (Review and Launch
)!
Launch!
If you'd like to improve the security of your site, go ahead and configure security groups. If you're interested in launching a low-stakes instance for learning purposes (like I am), hit the blue button!
Create a key
In order to be able to access your instance from the terminal on your computer via SSH, you'll need a private/public key pair. That last button click should've activated this modal:
Move the key to your Working Directory
Once you've chosen a project-specific name and downloaded it, for convenience, you may want to move the key into your project folder.
I avoided the command line for this and literally dragged and dropped it from my 'downloads' folder into my project folder.
.gitignore the Key file
Make sure you add the .pem key file to your .gitignore file. That way it won't be exposed publicly when on your next commit/push.
Rename your Instance
Go back to the Instances page. The same page you see at step 4. Rename your instance (I recommend naming it identically to your project).
Find your IP Address
Enter into your instance by clicking the blue Instance ID
link at the above page.
Connect to your Instance
Alright, we're right at the doorstep.
Let's enter into your instance console via SSH. Here's how.
Run this command from your project directory in your terminal:
ssh -i KEYNAME.pem ec2-user@IPADDRESS
(if you're using an ubuntu server, replace ec2-user
with ubuntu
)
replacing KEYNAME with the name of your key and IPADDRESS with the info copied a few steps earlier. (ec2-user
should be the default user name if you've followed the exact steps I've provided).
hit enter
.
If you get this message:
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Type yes
Change Key Permissions
If you see the following message:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'SDC.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "SDC.pem": bad permissions
ec2-user@18.118.34.126: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
enter this command:
`chmod 400 KEYNAME.pem'.
Again, replace KEYNAME
with the name of your key.
SSH again
Run this command a second time:
ssh -i KEYNAME.pem ec2-user@IPADDRESS
(don't forget to replace with the correct name/address).
et Voila!
If you see a command prompt like this:
[ec2-user@ip-172-31-29-141 ~]$
you've made it!
Top comments (0)