Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ How to run commands remotely on an EC2 Instance with AWS Systems Manager

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š How to run commands remotely on an EC2 Instance with AWS Systems Manager


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Systems Manager is a good choice when you need to view operation data for groups of resources, automate operational actions, understand and control the current state of your resources, manage hybrid environments, and maintain security and compliance.

  • Using the run command, one of the automation features of Systems Manager, you can simplify management tasks by eliminating the need to use bastion hosts, SSH, or remote PowerShell.

In this article, I am going to show you how to update the packages on an EC2 instance. At first, you will create an Identity and Access Management (IAM) role, enable an agent on your instance that communicates with Systems Manager, then follow best practices by running the AWS-UpdateSSMAgent document to upgrade your Systems Manager Agent, and finally use Systems Manager to run a command on your instance.

Please visit my GitHub Repository for EC2 articles on various topics being updated on constant basis.

Letโ€™s get started!

Objectives:

1. Create an Identity and Access Management (IAM) role

2. Create an EC2 instance

3. Update the Systems Manager Agent

4. Run a remote shell script

Pre-requisites:

  • AWS user account with admin access, not a root account.
  • Create an IAM role

Resources Used:

IAM
EC2
AWS Systems Manager

Steps for implementation to this project:

1. Create an Identity and Access Management (IAM) role

1

Image description

2

Image description

3

Image description

  • Next

4

Image description

5

Image description

6

Image description

  • Create role

2. Create an EC2 instance

Attach a Systems Manager role to Amazon Elastic Compute Cloud (Amazon EC2) instances to make them managed nodes.

1

Image description

2

Image description

3

Image description

4

Image description

5

Image description

6

Image description

7

Image description

3. Update the Systems Manager Agent

Now that you have an EC2 instance running the Systems Manager agent, you can automate administration tasks and manage the instance. In this step, you run a pre-packaged command, called a document, that will upgrade the agent. It is best practice to update the Systems Manager Agent when you create a new instance.

1

Image description

2

Image description

3

Image description

4

Image description

5

Image description

6

  • type in AWS-UpdateSSMAgent
  • then press Enter
  • select the radio button on the left of AWS-UpdateSSMAgent.
  • This document will upgrade the Systems Management agent on the instance

Image description

7

Image description

  • Run

8

  • you will see a page documenting your running command, and then overall success in green. Image description

9

Image description

4. Run a remote shell script

Now that your EC2 instance has the latest Systems Manager Agent, you can upgrade the packages on the EC2 instance.

  • In this step, you will run a shell script through Run Command.

1

Image description

2

Image description

3

  • On the Run a command page, click in the search bar and
  • select, Document name prefix,
  • then click on Equals,
  • then type in AWS-RunShellScript
  • then press Enter

Image description

4

  • On the Command Parameters panel and insert the following command in the Commands text box:

sudo yum update

Image description

5

Image description

  • Run

6

  • While your script is running remotely on the managed EC2 instance, the Overall status will be In Progress.

Image description

7

  • Then the Overall status will turn to Success.
  • When it does, scroll down to the Targets and outputs panel and select the Instance ID of your instance.
  • Your Instance ID will be different than the one pictured.

Image description

8

  • select the header of the Output panel to view the output of the update command from the instance.

Image description

Cleanup

Delete EC2 Instance

What we have done so far

Successfully created an EC2 instance and remotely run a command using AWS Systems Manager. You first set up a correct role/permissions through IAM. Next you launched an Amazon Linux instance that was preinstalled with the Systems Manager agent. Finally, you used Run Command to update the agent and remotely perform a yum update.

...



๐Ÿ“Œ How to run commands remotely on an EC2 Instance with AWS Systems Manager


๐Ÿ“ˆ 77.96 Punkte

๐Ÿ“Œ Beginner's Guide: Connecting to Your EC2 Instance Using AWS Systems Manager (SSM)


๐Ÿ“ˆ 47.84 Punkte

๐Ÿ“Œ How to Select the Right EC2 Instance โ€“ A Guide to EC2 Instances and Their Capabilities


๐Ÿ“ˆ 44.99 Punkte

๐Ÿ“Œ Configuring and Launching an EC2 Instance: A Comprehensive Guide with Detailed Commands


๐Ÿ“ˆ 40.76 Punkte

๐Ÿ“Œ SSH to your AWS EC2 instances using EC2-connect eice using this alias


๐Ÿ“ˆ 36.93 Punkte

๐Ÿ“Œ How to Fetch the AWS EC2 Instance ID


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ AWS EC2 Instance Store vs EBS


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Deploy cPanel & WHM on AWS EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How to Setup a Kubernetes Cluster on an AWS EC2 Instance?


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How to Create EC2 Instance (Ubuntu 22.04) on AWS and Connect Via SSH using PEM


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Get Started with Virtual Machines: A Step-by-Step Guide to Setting up an EC2 Instance on AWS.


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ The Why-What-How of AWS EC2 Instance Metadata Service update (IMDSv2)


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How to add swap to AWS EC2/Lightsail Amazon Linux instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Installing Ansible on AWS EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Azure Virtual machine & AWS EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Explore AWS Cloud9! Environment Creation with EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How To Install Oceanbase on an AWS EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How to Connect to Your AWS EC2 Instance with Visual Studio Code


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Choosing the Right AWS EC2 Instance: Avoiding Common Pitfalls


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Pros, Cons, and traps of EC2 Instance Start and Stop Schedules with AWS Lambda


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How To Understand and Choose Your First EC2 Instance on AWS


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Optimizing Your AWS EC2 Windows Instance: A Comprehensive Guide to Extending Root Volumes and Adding Extra Storage


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Deploy an EC2 Instance in AWS, connect to it and install nginx


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How to launch AWS EC2 Instance (Windows)


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ AWS Under the Hood - Day 3 - How does an EC2 instance get an IP address?


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How To Set Up An EC2 Instance on AWS


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ How to deploy an AWS EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Install Apache Web Server in Ubuntu AWS EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Launch and Connect to AWS EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Step-by-Step Guide to Setting Up Your First AWS EC2 Instance


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Deploying Next.js application on an Amazon EC2 instance (AWS)


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Why do I only see the private IP address when logged into an AWS EC2 instance?


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ Instance Discovery, Agent Install, and Configuration Management with Instance Manager


๐Ÿ“ˆ 34.51 Punkte

๐Ÿ“Œ Access EC2 Instances Privately Using AWS Systems Manager


๐Ÿ“ˆ 32.88 Punkte











matomo