This is a post for all those beginners just starting off with AWS. I know how frustrating it is to just get beginner level help in an environment where everyone seems to be a server ops expert.
So let’s discuss how to access your new server via SSH.
Wait, why the heck would a beginner ever SSH into a server?
Believe it or not, now that you’re on AWS, all those server administration tasks that were taken for granted are going to haunt you at every corner. You’ll have a newfound appreciation for what hosting providers do and that pesky cPanel you’ve grown to love and hate.
For example, you may have to change file or folder permissions, restart a service like Apache, or modify something that would typically cost time and money if you enlist a contractor. So be awesome and just try to do it yourself!
So here we go with some basics:
Primary Usernames for EC2 Instances:
I wish someone told me this when I first started playing with AWS. You’ll find these type of treasures hidden in Q&A threads, but not in any easy to understand guide in AWS documentation. Depending on the type of EC2 instance you have setup, below are the default / primary usernames:
- “ec2-user” (Amazon Linux, Red Hat Linux, SUSE Linux)
- “root” (Red Hat Linux, SUSE Linux)
- “ubuntu” (Ubuntu Linux distribution)
- “fedora” (Fedora Linux distribution)
Identify your Ec2 Instance Name
To SSH into your EC2 instance, you’ll need to grab its the EC2 Public DNS URL. It will look something like below:
To find this Public DNS URL, do the following:
- Login to AWS Console – http://aws.amazon.com/
- Click on Services on the nav menu, and then select EC2. Click on the Running Instances link
- Select the EC2 Instance and make note of the Public DNS URL. That will be the URL you will use to SSH into the server.
Commands to SSH into EC2 Instance:
Next, let’s get to actually logging into your EC2 instance. To do so, you’ll have to open Terminal (on a Mac), or a SSH client like Putty (if on PC). Then, use the command below based on the type of instance you have. Pay attention to the difference in the primary username.
If Amazon Linux or Red Hat Linux EC2 instance:
ssh -i path/to/AccessKey.pem email@example.com
If Red Hat Linux or SUSE Linux EC2 instance:
ssh -i path/to/AccessKey.pem firstname.lastname@example.org
If Ubuntu EC2 instance:
ssh -i path/to/AccessKey.pem email@example.com
If Fedora Linux EC2 instance:
ssh -i path/to/AccessKey.pem firstname.lastname@example.org
If necessary, see this guide on how to fix the permission error when SSH into EC2 instance on AWS
That’s it. That’s as short as I can keep this post.
Here’s some additional reading material that I think may be helpful:
- AWS – Connecting to Linux Instances
- How to fix the permission error when SSH into EC2 instance on AWS
That’s it! Keep learning…