Created
August 12, 2023 00:11
-
-
Save nicobn/8c76b4829a604dea03caa68289f66495 to your computer and use it in GitHub Desktop.
Get a file from an instance using SSM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assumptions: | |
# - SSM agent is installed on instance | |
# - Netcat is installed on instance | |
# - Port 1234 is accessible and no other process is listening | |
# Set instance id | |
export INSTANCE_ID="i-123123123" | |
# Shell 1: Start session | |
aws ssm start-session --target $INSTANCE_ID | |
# In shell 1: Start netcat listener | |
cat filename | nc -l -p 1234 | |
# Shell 2: Start port forwarding | |
aws ssm start-session --document-name AWS-StartPortForwardingSession --parameters '{"portNumber":["1234"],"localPortNumber":["1234"]}' --target $INSTANCE_ID | |
# Shell 3: Start netcat client | |
nc -w 3 127.0.0.1 1234 > filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment