Aug 06

Adding users to Linux EC2 instance and give SSH access

The default AWS Linux EC2 instances come up with one user account such as centos, ubuntu etc  with sudo privileges.
However in complex environment you may be needed add more users to EC2 instance with different privileges. Here we are going to discuss
how to adding users to Linux EC2 instance and give SSH access to the accounts. At the end of the tutorial we give you a trick to make the user
into sudo user.

1) Create new user account

2) Switch into new user account

3) Generate new private key from AWS Account.

Log into AWS Account, then Goto “EC2” , next select “Key Pairs” under “NETWORK & SECURITY” which can find from left hand side.

EC2 key pair generator

4) How to obtain public key ??

i) Copy *.pem file into Linux machine.

ii) Run following command

This will will be asked to enter private key, then enter previously copied *.pem file

iii) Copy output file

example output :-

5) Create a .ssh directory for the authorized_keys file.

you may need to switch into “newuser”

6) Change the file permissions of the .ssh directory

7) Copy public key into authorized_keys and set permission to file

8) Log into server with .pem file

[root ~]$ssh -i your_private_key.pem newuser@remote.server.ip.address

ex :- ssh -i user.pem newuser@

9) how to make new user into root or sudo user

this will require password, so we are going to disable this

log into remote server

add following

Reference :- http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html

Leave Your Thought Here