Run Command Remotely on EC2 instance

Run Command Remotely on EC2 instance

March 24, 2021 / Nirav Shah

Run Command Remotely on EC2 instance: AWS Manager

Learn how to manage Instance using AWS-SSM and how we create a session manager for the system.

Step 1: Create an IAM role that will be used to give the Systems Manager permission to perform actions on your instances.

choose EC2 and On the Attached permissions policy page, in the search bar type AmazonEC2RoleforSSM then from the policy list, then select AmazonEC2RoleforSSM, and then choose Next: Review.

Run Command Remotely on EC2 instance

Step 2: Create an EC2 instance

In this step, you will create an EC2 instance using the EnablesEC2ToAccessSystemsManagerRole role.

Run Command Remotely on EC2 instance

Step 3: Update the Systems Manager Agent. Open Systems Manager from the Systems Manager console.

Run Command Remotely on EC2 instance

Step 4: On the Managed instances page, in the Actions drop-down select Run Command.

Run Command Remotely on EC2 instance

Step 5: On the Run command, click in the search bar and select Document name prefix, then click on Equal, then type in AWS-UpdateSSMAgent.

Scroll down to the Targets panel and click the check box next to your managed EC2 instance.

Run Command Remotely on EC2 instance

Step 6: Run a Remote Shell Script

From the Systems Management console, in the left nav under Shared Resources select Managed instances. Then in the Actions menu, select the Run Command menu item.

Run Command Remotely on EC2 instance

Step 7:

Run Command Remotely on EC2 instance

Step 8: Insert the following command in the Commands text box:

sudo yum update -y

Finally, scroll down and select Run.

Run Command Remotely on EC2 instance

Now check in your EC2 Instance for the output. This is how you can run the command remotely on EC2 instance.

Talk to AWS Certified Consultant

    Spread Love By Sharing:

    Let Us Talk About Your AWS Development Requirements

    Have queries about your AWS project ideas and concepts? Please drop in your project details to discuss with our AWS experts, professionals and consultants.

    • Swift Hiring and Onboarding
    • Experienced and Trained AWS Team
    • Quality Consulting and Programming
    Let’s Connect and Discuss Your Project