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:
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 :
2 - Load the *.pem key file you downloaded from AWS.
3 - Save the key
4 - Open a new putty session and type the ipaddress of the ec2 instance:
Go to SSH - Auth, and paste the full patf to the new generated key.
Now you should be good to go and connect to the ec2 instance using the key and any other user you choose.