Why does Ubuntu EC2 Instance ask you login as the user “Ubuntu”?
Have you ever wondered why Ubuntu EC2 Instance asks you to log in as the user “ubuntu” when you log in as the “root” and subsequently crash?
Let me explain it in detail.
In the final steps of spinning up an AWS Instance, you will be asked to download a key pair.
A key pair consists of a public key that AWS stores, and a private key file that you store. Together, they allow you to connect to your instance securely. For Windows AMIs, the private key file is required to obtain the password used to log into your instance. For Linux AMIs, the private key file allows you to securely SSH into your instance.
The key pair that will be allowed for you to download is nothing but a private key file (*.pem file) before you can continue. Store it in a secure and accessible location. As you will not be able to download the file again after it’s created.
Step 1:
Go to PuTTYgen app.
Load the .pem private download while launching an EC2 Instance
Save the private key in .ppk format.
Step 2:
Post downloading it. Go to PuTTY (SSH Client App) to login to the server by authenticating your key.
In the “Host Name” bar, enter your server's Public IPV4 address.
Then click on SSH -> AUTH, and load the private downloaded in .ppk format.
Then you’ll log in to the server.
Step 3:
After you logged into the server, if you want your login as the “root” it will throw an error saying you have to login as the user “ubuntu”.
This is because the default user name is “ubuntu”. And the private key that is used to authenticate with the public key is also for the user “ubuntu”.
So, you have to login as the user “ubuntu” first and then execute the command “sudo su” to be redirected as the root user.
To come out from “root” user back to sudo, execute the command “exit”