DEV Community

Mohana Priya
Mohana Priya

Posted on

Creating and Managing IAM Users from Your EC2 Instance

Introduction:
Managing user access on your EC2 instance is a fundamental task for maintaining security and efficiency in your AWS environment. In this guide, we'll walk you through creating a new user from the EC2 instance, setting up SSH access, and verifying the new user. Let's get started!

Step-1: Create a EC2 instance
Create a ec2 instance in the console.

Image description

Step-2: Connect to your EC2 instance
Connect to your EC2 instance using SSH. Open your terminal and run the following command

ssh -i path_to_your_key.pem ec2-user@your_ec2_public_dns

Enter fullscreen mode Exit fullscreen mode

Replace path_to_your_key.pem with the path to your private key file and your_ec2_public_dns with the public DNS of your EC2 instance.

Step-3: Create a new user
Once connected to your EC2 instance, you can create a new user. Use the following command, replacing new_username with the desired username:

sudo adduser new_username

Enter fullscreen mode Exit fullscreen mode

This command creates a new user and sets up a home directory for them.

Step-4: Set a password for the new user
Next, set a password for the new user. Use this command to set password for the new user.

sudo passwd new_username

Enter fullscreen mode Exit fullscreen mode

Step-5: Verify the New User
To verify that the new user has been created successfully, use this command

cat /etc/passwd

Enter fullscreen mode Exit fullscreen mode

You should see an entry similar to this:

new_username:x:1001:1001::/home/new_username:/bin/bash

Enter fullscreen mode Exit fullscreen mode

This confirms that the new user has been added to the system.

Image description

Image description

Conclusion:
Creating and managing users on your EC2 instance is a straightforward process that enhances your system's security and accessibility. By following these steps, you can efficiently add new users, set up SSH access, and verify their presence on your system.

Regularly review and manage user accounts to maintain a secure and organized environment. Happy managing!

Top comments (0)