2

I am trying to set up port forwarding between my local PC and an AWS EC2 based on the AWS SSM port forwarding article instance like this:

aws ssm start-session --target  i-0822c9a6c52ca7394 \
  --document-name AWS-StartPortForwardingSession --parameters \
 '{"portNumber":["55555"],"localPortNumber":["6666"]}'

I already use SSM to access the instance (using ssm-session) and have used it to start python -m SimpleHTTPServer 55555 listening on the port.

The output I get from SSM is just this:

Starting session with SessionId: jakub.holy@481473109573-0dd8f51cc06ef4469

(And, eventually, after a long while: SessionId: jakub.holy@481473109573-0dd8f51cc06ef4469 : Your session timed out due to inactivity and has been terminated. - and I still need to kill it.)

at which point it hangs. I have expected, but do not see, the following, right after "Startin session...":

Port 6666 opened for sessionId ....

Connection accepted for session .....

Any idea why is it hanging and not establishing the port forwarding?

Jakub Holý
  • 363
  • 1
  • 3
  • 14

2 Answers2

0

Make sure that you can write to the bucket used for session manager logging (if you have one), and make sure you also grant EC2 the action s3:GetBucketEncryption. See here for more information

Felipe Alvarez
  • 183
  • 2
  • 12
0

I got this tip from a colleague:

You might need update ssm-agent on EC2 instance before being able to use port-forwarding feature. When the agent doesn't support port-forwarding the session is hanging with no error message or ends with message "Session Timed out".

(I am using the agent baked into the Amazon Linux 2 instance, which was v. 2.3.662 while the newest is now 2.3.760.)

Jakub Holý
  • 363
  • 1
  • 3
  • 14