Member-only story
SSM Start Session Script
This is a Bash script designed to automate the process of checking and installing necessary tools, managing AWS credentials, and establishing an SSH session with an AWS EC2 instance using AWS Systems Manager (SSM) for port forwarding.
Overview of the Script
This script performs several key functions:
- Tool Installation: It checks whether the AWS CLI and the AWS Session Manager plugin are installed. If not, it installs them.
- Credential Management: The script verifies if an AWS session token is available using
saml2awsand prompts for login if necessary. - Instance Retrieval: It retrieves the EC2 instance ID based on a provided instance name.
- Session Management: Finally, it opens an SSM port forwarding session to the specified instance.
Prerequisites
Before diving into the script, ensure you have the following prerequisites:
- A Unix-based system with Bash support.
- Sudo privileges for installing necessary tools.
saml2awsconfigured for SAML authentication.- An SSH configuration that allows connections over AWS SSM.





