We are going to create two users who can login to EC2 instance using their own userid’s instead of root user/key.
1. Login to AWS console and create key pairs which match with userid’s (This is just a convention)

For example I am going to create two users,

jadhavv & oracle so I will create key pairs named – jadhavv & oracle



2. Download both keys to your local machine.

-rwx——@ 1 VJ-HOME staff 1692 3 Jun 02:38 oracle.pem.txt
-rw-r–r–@ 1 VJ-HOME staff 1692 3 Jun 03:21 jadhavv.pem.txt

chmod 700 *.pem.txt

3. Then extract the public key from above files,

Vijays-iMac:Downloads VJ-HOME$ ssh-keygen -y
Enter file in which the key is (/Users/VJ-HOME/.ssh/id_rsa): /Users/VJ-HOME/Downloads/jadhavv.pem.txt
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn55IhK1qVZGedDEHFzR2+j9tfI1t2CNzPPsxamyRiYA1dgWMO2I6hOPL0enttXK6COuWphghvqNvyecYCOt9Xc/Ym36jsdFQJy/BwWdKAfpD9Qj4Izpc34dayjq3qcG4pYFFVmaw1qdxPwAIbJC+UvcYC/Dn03HnDinocT1vLvXzhvmsN/YoozOzWFy22n80PdeW3A0HYr8xJtaXmtRY42SAiEf6odr/BFr9iFcNAfJ5iTA431Yg6rFzy5gXJUuOC8CnYljOc/975C6/pe2FjQABUiKGY5OWLjb6ImAmbMUJdZuuQDiIcHVdkC4AJHbZct64Xgpo61/7zwLgx+pvJ
Vijays-iMac:Downloads VJ-HOME$

4. Login to your EC2 instance with root

[root@ip-10-0-1-37 ~]# useradd jadhavv
[root@ip-10-0-1-37 ~]# su – jadhavv
[jadhavv@ip-10-0-1-37 ~]$

[jadhavv@ip-10-0-1-37 ~]$ mkdir .ssh
[jadhavv@ip-10-0-1-37 ~]$ chmod 700 .ssh/
[jadhavv@ip-10-0-1-37 ~]$ touch .ssh/authorized_keys
[jadhavv@ip-10-0-1-37 ~]$ chmod 600 .ssh/authorized_keys
[jadhavv@ip-10-0-1-37 ~]$ vi .ssh/authorized_keys
Add the public key extracted in step 3 to .ssh/authorized_keys

5. Login with the user and it’s corresponding private key from your local machine

Vijays-iMac:Downloads VJ-HOME$ ssh -i jadhavv.pem.txt jadhavv@
Last login: Fri Jun 2 22:22:39 2017
[jadhavv@ip-10-0-1-37 ~]$
[jadhavv@ip-10-0-1-37 ~]$ id
uid=1002(jadhavv) gid=1002(jadhavv) groups=1002(jadhavv) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[jadhavv@ip-10-0-1-37 ~]$


That it !