How to connect to an EC2 instance with non ec2-user

By default the AWS EC2 instance come with the ec2-user access enabled via access keys. If we choose to keep the key access only and try to create other users that require access to the host we need to make some changes. Error Message :

Please login as the ec2-user user rather than "user X " user.

Before we go into more details i assume you have a user on the EC2 instance you wanna connect, can be root or any new user.
You need to create the folder .ssh in the new user home and do the following steps:
mkdir /home/<user/.ssh
cp /home/ec2-user/.ssh/authorized_keys  home/<user/.ssh/
chmod 700 /home/<user/.ssh
chmod 600 /home/<user/.ssh/authorized_keys
chown -R <user:<usergrp /home/<user/
Next you need to create private key using the public key you were using to log in as ec2-user. Follow the steps bellow: 1 - Open the putty Key Generator : putty1 2 - Load the *.pem key file you downloaded from AWS.  putty2 putty3 putty4 3 - Save the key putty5 4 - Open a new putty session and type the ipaddress of the ec2 instance:  putty6 Go to SSH - Auth, and paste the full patf to the new generated key. putty7 Now you should be good to go and connect to the ec2 instance using the key and any other user you choose.