- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
Install AWS CLI and Session Manager Plugin:
Make sure you have the AWS CLI and Session Manager plugin installed on your local machine.
AWS CLI Installation:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
session Manager Plugin Installation:
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac/sessionmanager-bundle.zip" -o "sessionmanager-bundle.zip"
unzip sessionmanager-bundle.zip
sudo ./sessionmanager-bundle/install -i /usr/local/sessionmanagerplugin -b /usr/local/bin/session-manager-plugin
Start a Session Manager Session with Port Forwarding:
Use the AWS CLI to start a Session Manager session with port forwarding. This command forwards traffic from your local port 8080 to port 8080 on the EC2 instance.
aws ssm start-session \
--target i-0123456789abcdef0 \
--document-name AWS-StartPortForwardingSession \
--parameters '{"portNumber":["8080"],"localPortNumber":["8080"]}'
Verify the Tunnel:
On your EC2 instance, you should now be able to access your local web application by running:
curl http://localhost:8080
Detailed Explanation
AWS CLI and Session Manager Plugin:
These tools are necessary to interact with AWS services and establish the Session Manager session for port forwarding.
Start a Session Manager Session:
The aws ssm start-session command starts a session with port forwarding. The --document-name AWS-StartPortForwardingSession specifies the type of session, and the --parameters option specifies the local and remote ports to forward.
Accessing the Application:
Once the session is established, any traffic to localhost:8080 on the EC2 instance is forwarded through the tunnel to localhost:8080 on your local machine, allowing the EC2 instance to access the web application running on your local machine.
Contenuto pertinente
- AWS UFFICIALEAggiornata 9 mesi fa
Hi Thanniru, Thanks for your response. I have tried to do port forwarding from my local machine. It says Cannot perform start session: listen tcp 127.0.0.1:8080: bind: address already in use
Because there is a service already running in 8080 in my local machine. I want to do a reverse port forwarding from local to remote