overexchange
overexchange

Reputation: 1

How to connect to Amazon EC2 instance?

After I created a ubuntu VM(Amazon EC2 instance), I see below entry in "view instances":

I see public dns as Public DNS: ec2-13-58-17-118.us-east-2.compute.amazonaws.com

Instance: i-08c551d9713dfcd06 (ubuntu_VM)

Security groups: sg_ubuntu. view inbound rules. view outbound rules


To connect to this Amazon EC2 instance(ubuntu VM), am using below syntax from my ubuntu laptop:

ssh -i "ubuntu_key.pem" ubuntu@ec2-13-58-17-118.us-east-2.compute.amazonaws.com

and it works, but I do not know the reason, for its working

I understand that ec2-13-58-17-118.us-east-2.compute.amazonaws.com is domain name


1) What is ubuntu in ubuntu@ec2-13-58-17-118.us-east-2.compute.amazonaws.com?

2) Why Amazon EC2 instance creation process does not ask for assigning hostname to the EC2 instance, on aws website? after sshing, I see some dynamic hostname assigned(ip-172-31-30-203) which is not good for me...

3) What is security group? amidst creation of EC2 instance...

Upvotes: 2

Views: 1634

Answers (2)

Alain Cruz
Alain Cruz

Reputation: 5097

1) ubuntu is the username of that particular ec2 instance. In this case, since your instance is using Ubuntu, then by default you get that username. If you had created an instance using Amazon Linux 2, it would of have been ec2-user. You can check more here.

If you intend to change this username, you can in fact. Just like you would in any Linux OS, except for a few extra steps you need to follow in order to connect using SSH with this new username.

2) Each time you stop and restart your Amazon EC2 instance (unless you are using an Elastic IP address), the public IPv4 address changes, and so does your public DNS name, system hostname, and shell prompt. This is found in the user guide. If you want to have a static IP, you must create an Elastic IP address, although, it has a cost.

3) The security group, is a set of rules of how to access (inbound rules) your instance and what can your server reach (outbound rules). By default, if not mistaken, in your inbound rules, you should only have your SSH connection available.

Upvotes: 3

ScottBurfieldMills
ScottBurfieldMills

Reputation: 196

  1. ubuntu is the username on the server
  2. I'm not sure why this is, but you are able to change it using the command sudo hostnamectl set-hostname your-desired-hostname. You can read more in the AWS UserGuide
  3. Security groups are firewall rules that you can use to protect your VM from the outside world. You can block access to specific ports, only allow access to specific ports from an IP address or IP range. For example, you can use it to restrict access to SSH only to your office IP address to prevent anyone else from logging into your EC2 instance.

Upvotes: 1

Related Questions