Connect to an AWS EC2 Instance with SSH

Sam Julien
InstructorSam Julien
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

Now that our EC2 and database are set up, we need to actually connect to the server so that we can do what we set out to do: install Ghost!

There are a few ways that EC2 lets you connect but we will be using the SSH client. To do so, you'll need to find your ssh key file, modify the file permissions, and we will use that key file in combination with the public DNS of the EC2 server to SSH into the server. Since our own IP address is explicitly allowed we will be able to do so!

Instructor: [0:00] We've got our database set up and our EC2 instance launched. Now we need to SSH log into our server so we can start installing some software to get Ghost up and running.

[0:13] Go back over to our EC2 instance. Click over into EC2. Click into instances. You can see our Ghost server here. Let's go ahead and click into that.

[0:26] AWS provides some handy instructions for us and how we can connect to our server here. I can click on connect. You can see there's three options here, instance connect, session manager, and SSH client. We're going to use an SSH client here.

[0:42] What we'll need to do is find our private key file and modify the permissions, and then connect to our server. I am going to go ahead and copy over this long command here.

[0:54] Notice one thing. This 3-22, all the way to 223, this is the public IP address of our EC2 instance. You can see that it's inserted here into this address for our EC2 instance.

[1:09] I'm going to hop back over to our terminal. I've got my private key over in this /dev directory here. The first thing we need to do is make sure that our key has the right permissions. We want to turn on read permissions for our user, but turn off everybody else's permissions. We don't want anybody to be able to read, write or execute this file.

[1:31] We can do that with chmod and then 400 and then the name of the file, which is ghostkey.pem. I'm going to go ahead and hit enter there. That'll update those permissions. Now, I'm going to go ahead and paste our SSH command into the terminal.

[1:48] What's happening here is we're doing this SSH. We're specifying the key that we want to be able to use, and then we're specifying the address that we want to SSH into. Go ahead, and hit Enter. The first time you do this, you're probably going to see a prompt asking you to add this to a list of places that you can SSH into. Go ahead, and hit Yes if you see that.

[2:12] You can see now that I'm in the server. If I scroll up a bit, you can see this "Welcome to Ubuntu" message. You can see we have some updates that need to happen, and we'll do that shortly. This is how you log into the server. You're in the EC2 instance right now, logged in.

egghead
egghead
~ 7 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today