Root access credentials for EC2 instance procured using AWS console

I am new to cloud technologies, we as a team works on big data for a US client and resources are on AWS EC2 instances. Whenever our client gives us access, it gives us two types of credentials. Root access credentials and sudoer user.

When I have procure an EC2 instance using AWS console. I have ppk and pem keys with me. But still when I login with ec2-user I have sudoer permissions.
How can I get root access credentials to that EC2 machine.

Hi Kushal,

You can do this in 3 different ways

  1. Login into EC2 machine using credentials (.ppk and .pem key files)
  2. Login into EC2 machine as “Normal User”
    3)Login into EC2 machine as “RootUser”

Login into EC2 machine using credentials (.ppk and .pem key files)

To Enable login into EC2 machine as “Normal User”
Login into EC2 machine using credentials(ppk and pem files) and perform the following steps:

  1. Add user using following command
    sudo useradd username
  2. Set password for user.
    sudo passwd user
  3. Edit /etc/ssh/sshd_config

    Default will be “no” , make it yes.
  4. Save and quit the file
  5. Restart sshd service
    sudo service sshd restart
  6. Logout of the machine.
  7. Lets try login into EC2 machine as normal user which you have created.
    ssh username@EC2endpoint.

To enable login into EC2 machine as “RootUser”

  1. Login as root user
  2. Add user using following command
    sudo useradd username
  3. Set password for user.
    sudo passwd user
  4. Add created user into sudoers file.
    i) cd /etc
    ii) visudo
    Add another line as shown below

    Edit as following
  5. Edit /etc/ssh/sshd_config

    Default will be “no” , make it yes.
  6. Save and quit the file
  7. Restart sshd service
    sudo service sshd restart
  8. Logout of the machine.
  9. Lets try login into EC2 machine as Root user which you have created.
    ssh username@EC2endpoint.

Hi Team,

Please refer attached screenshot and let me know if I am going in wrong direction.
If I am logging using “ec2-user” I am able to login.

rootuser_access_screenshots.pdf (1.1 MB)

Got the answer
simple login with ppk as ec2-user
once login then enter following command you become root user and then you can modify the same

“sudo su -” + Press Enter