steps to login to EC2 Linux Instance without SSH keypair

In this blog, we will show you the steps to login to EC2 Linux Instance without SSH Keypair.

 

ENVIRONMENT OVERVIEW

 

  • We have created an EC2 Linux Instance without a key pair.

steps to login to EC2 Linux Instance without SSH keypair

 

CREATING IAM ROLE

 

  • Open the IAM service from the AWS Management Console.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Click on Roles Option.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Then click on Create role button.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Select the EC2 service and click on the Next button.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Search for AmazonEC2RoleforSSM and select it and click on Next.

steps to login to EC2 Linux Instance without SSH keypair

 

  • We haven’t added any Tags for this demo. Click on Next.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Provide the name and description for this role and click on Create role button.

steps to login to EC2 Linux Instance without SSH keypair

 

  • The role has been created successfully.

steps to login to EC2 Linux Instance without SSH keypair

 

ADDING INLINE POLICY

 

  • Open the newly created role and click on Add Inline Policy.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Click on JSON Tab and paste the below script.

steps to login to EC2 Linux Instance without SSH keypair

 

{
   "Version": "2012-10-17",
   "Statement": [
     {
       "Effect": "Allow",
       "Action": [
         "ssm:PutParameter"
       ],
       "Resource": [
         "arn:aws:ssm:region:account_id:parameter/EC2Rescue/Passwords/<instanceid>"
       ]
     }
   ]
}

 

  • Update the region, account ID and Instance ID and click on Review policy.

 

steps to login to EC2 Linux Instance without SSH keypair

 

Note:  You can find the above code in this URL: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2rw-ssm.html

 

  • Provide a name and click on create policy.

steps to login to EC2 Linux Instance without SSH keypair

 

  • The In-policy is created successfully.

steps to login to EC2 Linux Instance without SSH keypair

 

CREATING AN ENCRYPTION KEY

 

  • Search for KMS in the AWS Management console.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Click on the Customer Managed Keys.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Click on the create key button.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Provide the Alias and Description and click on the Next button.

steps to login to EC2 Linux Instance without SSH keypair

 

  • No tags were provided for this key. Click Next to continue.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Search for the role which we created earlier and select it.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Select the same IAM role which we created earlier to Define key usage permissions and click Next.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Review the policy and click on the Finish button.

steps to login to EC2 Linux Instance without SSH keypair

 

ATTACH AN IAM ROLE TO AN INSTANCE

 

  • Open the EC2 Management Dashboard and click on the Instances link.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Select the instance and click on Actions – Instance Settings – Attach/Replace IAM Role link.

steps to login to EC2 Linux Instance without SSH keypair

 

  • Select our newly created IAM role from the drop-down list and click on the Apply button.

steps to login to EC2 Linux Instance without SSH keypair

 

  • IAM Role has been added successfully.

 

ASSIGNING THE KMS TO SESSION MANAGER

 

  • Search for SSM in AWS Management Console.

steps to login into EC2 Linux Instance without SSH key pair

 

  • Select the Session Manager link.

 

  • Then click on the Preferences Tab.

 

  • Then select the Edit Button.

 

 

  • Click on the Key Management Service (KMS) checkbox under the preferences section.

 

  • Scroll down and select our newly created key in KMS. In addition, click on the Save button.

 

  • Now our KMS key has been associated with the Session Manager.

 

 

RESET THE ROOT USER PASSWORD

 

  • Search for SSM in AWS Management Console.

steps to login into EC2 Linux Instance without SSH key pair

 

  • Click on Managed Instances under Instances & Nodes topic and make sure that your instance is available in the list.

 

 

  • Select the instance and click on the Reset password.

 

  • It will prompt you to update the SSM client. Click on the update button.

 

  • After a few seconds, It will prompt you the text box to provide the username. Type root and click on Submit.

 

  • Now type the new password twice for the root account and click Done.

 

  • Scroll down and click on the session manager link under Instances & Nodes section.

 

  • Click on the Start session.

 

  • Now select the instance and again click on the start session.

 

  • A session window will open for your selected instance.

 

ENABLING THE ROOT USER ACCESS

 

  • First, change to root user using su – root command.

steps to login into EC2 Linux Instance without SSH key pair

 

  • Go to /etc/ssh/ and open sshd_config through VI Editor.

 

  • Permit the root login by removing the # tag.

 

  • Also, please enable password authentication in addition to saving the changes.

 

  • Save and exit the Editor.

 

  • Restart the SSHD service using the below command.

systemctl restart sshd.service

 

 

VERIFICATION

 

  • Access the Linux EC2 Instance using public IP through SSH.

steps to login into EC2 Linux Instance without SSH key pair

 

 

  • We are able to login to the EC2 Linux instance using root account without SSH key Pair.

REFERENCE

Keypair

 

Thanks for reading this blog. We hope it was useful for you to know about the steps to login to EC2 Linux Instance without SSH keypair

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn
More Interested Related Posts
zfs pool usage

ZFS Pool and Dataset Usage

ZFS Pool and Dataset Usage   I am back with another blog to provide the useful script to the Freebsd users to determine the zpool

Assistanz Networks

Installing Zabbix Agent in FreeBSD 12.0

Zabbix Agent Installation and Configuration Guide on FreeBSD 12.0   Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual

DirectAdmin Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk
$ 99 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • NDA & SLA
  • SLA Review Meetings
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation
  •  

Platinum Support

24/7 Proactive Support
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Support

$ 30 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response Time
  • 4 Hours Resolution time for the Possible Issues
  • Security and Performance Optimization
  • React to Customers queries
  • Simple SignUp Process
  • Instant Account Activation
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support