Add new user to EC2 instance with SSH Key access

Views:
 
Category: Education
     
 

Presentation Description

https://linuxdady.com/add-new-user-to-ec2-instance-with-ssh-key-access/ Add new user to EC2 instance with SSH Key access. I think you know very well when we launch a new EC2 instance in Aws. Then it will launch with default user ec2-user . It’s depends on your Operating system which one you are using Redhat, Ubuntu, or anything else. EC2 default user is ok if you are learning Aws cloud.

Comments

Presentation Transcript

slide 1:

LinuxDady.Com Add new user to EC2 instance with SSH Key access For more information visit https://linuxdady.com

slide 2:

Add new user to EC2 instance with SSH Key access Add new user to EC2 instance with SSH Key access. I think you know very well when we launch a new EC2 instance in Aws. Then it will launch with default user ec2-user . It’s depends on your Operating system which one you are using Redhat Ubuntu or anything else. EC2 default user is ok if you are learning Aws cloud. But if you are using Aws cloud in your production then you have to change ec2 instance default user according to your project requirement. In this article we will add new user to EC2 instance with SSH key access and will change default ec2- user. Before doing practical be ready with below requirement. 1 AWS console access 2 EC2 instance 3 SSH key Step 1: – Add new users to EC2 instance with SSH Key access Login to your Aws account and launch a new EC2 instance. If you have already EC2 instance then no need to launch new instance. In my case I am choosing redhat ec2 instance. Click Read: – How to create VPC in aws cloud environment Step 2: – Access your EC2 instance from putty

slide 3:

In this step we will take access of EC2 instance and we will add new user to EC2 instance with SSH Key access. Follow the step. First login to your instance. When you will click on open it will ask for username. Remember one thing your default user is ec2-user. Login with your default ec2-user into your EC2 instance.

slide 4:

Step 3: – Add new user according to your need Now you have to add a new user according to your project requirement. By this user you can take your ec2 instance access. In my case I am adding linuxdady as a user. Also give sudo user access to your user. 1 visudo I hope you know very well how to add user into sudo supper user list Let’s move to next step. Step: 4 Generate SSH key file of login If you have already your key file then no need to generate new SSH key file. You can use that key file. If you don’t have than you have to create new key file. You can use common key file for all EC2 instances. It’s depended on your requirement. Let’s generate an SSH key file for login.

slide 5:

1 ssh-keygen -t rsa You public and private key file has been create into .SSH directory. Go to .SSH directory and check once. Now create an authorized_keys file and copy your public key here. 1 2 3 touch authorized keys cp -ivr id_rsa.pub authorized_keys chmod -R 400 authorized_keys

slide 6:

Your public key has been copied into authorized key. Remember one thing you have to copy your public key into authorized_keys file not private key. Step 5: – Copy your private key into notepad file and convert into .PPK file If you are using windows machine then copy your private key into notepad and save with .PEM extension like linuxdady-key.pem When you have copied properly your private SSH key into notepad then you have to change it into .PPK file. Because for windows we need .PPK file to access EC2 instance. If you are using Linux based operating system then create empty file with any editor copy your private key with .PEM extension. Click Read: – How to convert .pem file to .ppk file Step 6: – Access your EC2 instance with new user

slide 7:

When you have converted your key file successfully from .PEM to .PPK then login with your new user that you have recently created. Remember you have to select your new key file. When you will click on open then it will ask for username enter your username that you have created. Again remember one thing use those key files that you have recently created with putty gen. Step 7: – Disable default ec2-user login

slide 8:

We have successfully login with our desire user now we are going to disable default ec2-user because anyone can easily guess it. And if anyone get our key he can access our resource. So for security purpose we are going to disable ec2- user. But in your case depends on your requirement. Do only one thing to disable ec2-user login. Go to your .SSH directory and open authorized_key file and comment it with and take restart of SSH service. Conclusion To use default user is not good for your production environment because anyone can easily guess and can try for misuse. In this article we have explained how to add new user to EC2 instance with SSH Key access. We have added a user and show you practical login. If you have still any query write me in comment box. I will try my best to resolve that query. Interview point of view 1. Which permission we should assign for EC2 key file and why 2. Can we access multiple EC2 instance from single EC2 key file 3. Which one key is used to take access of EC2 instance from windows OS 4. What is difference between .PEM file and .PPK file Write your answer in comment box. Please keep answering.

authorStream Live Help