Closed GlauberrBatista closed 1 year ago
I upgraded to version 12 and later to version 13. The issue is still happening
Extra logs from tsh client:
2023-06-19T10:13:02-03:00 DEBU Started forwarding request for "ecs.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:357
2023-06-19T10:13:02-03:00 INFO [CA] Generating TLS certificate SERIALNUMBER=27943757550190476698131196842897322965,CN=ecs.us-east-1.amazonaws.com,O=Teleport dns_names:[ecs.us-east-1.amazonaws.com] key_usage:5 not_after:2023-06-19 23:19:01 +0000 UTC tlsca/ca.go:1111
2023-06-19T10:13:03-03:00 DEBU Stopped forwarding request for "ecs.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:363
2023-06-19T10:13:03-03:00 DEBU Started forwarding request for "ecs.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:357
2023-06-19T10:13:04-03:00 DEBU Started forwarding request for "ssmmessages.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:357
2023-06-19T10:13:04-03:00 INFO [CA] Generating TLS certificate SERIALNUMBER=27943757550190476698131196842897322965,CN=ssmmessages.us-east-1.amazonaws.com,O=Teleport dns_names:[ssmmessages.us-east-1.amazonaws.com] key_usage:5 not_after:2023-06-19 23:19:01 +0000 UTC tlsca/ca.go:1111
2023/06/19 10:13:04 http: TLS handshake error from 127.0.0.1:57291: remote error: tls: bad certificate
2023-06-19T10:13:04-03:00 DEBU Stopped forwarding request for "ssmmessages.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:363
2023-06-19T10:13:04-03:00 DEBU Started forwarding request for "ssmmessages.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:357
2023-06-19T10:13:04-03:00 DEBU Stopped forwarding request for "ssmmessages.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:363
2023/06/19 10:13:04 http: TLS handshake error from 127.0.0.1:57293: remote error: tls: bad certificate
2023-06-19T10:13:05-03:00 DEBU Started forwarding request for "ssmmessages.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:357
2023/06/19 10:13:05 http: TLS handshake error from 127.0.0.1:57296: remote error: tls: bad certificate
2023-06-19T10:13:05-03:00 DEBU Stopped forwarding request for "ssmmessages.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:363
2023-06-19T10:13:05-03:00 DEBU Started forwarding request for "ssmmessages.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:357
2023/06/19 10:13:05 http: TLS handshake error from 127.0.0.1:57298: remote error: tls: bad certificate
2023-06-19T10:13:05-03:00 DEBU Stopped forwarding request for "ssmmessages.us-east-1.amazonaws.com:443". alpnproxy/forward_proxy.go:363
...
edit: add extra logs
Try adding --endpoint-url to your tsh command: tsh aws ecs execute-command --endpoint. These commands require the use of endpoint URL mode.
@TeleLos thank you for those new instructions. However, it's still not working as intended.
What I did:
$ tsh proxy aws --endpoint-url
Started AWS proxy which serves as an AWS endpoint URL at https://127.0.0.1:57090.
To avoid port randomization, you can choose the listening port using the --port flag.
In addition to the endpoint URL, use the following credentials to connect to the proxy:
export AWS_ACCESS_KEY_ID=<generated_key>
export AWS_SECRET_ACCESS_KEY=<generated_secret>
export AWS_CA_BUNDLE=<path_to_pem>/aws-localca.pem
then on another window:
$ tsh aws ecs execute-command --cluster <cluster_name> --endpoint-url https://127.0.0.1:57090 --task <task_id> --interactive --command "/bin/bash"
The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.
An error occurred (403) when calling the ExecuteCommand operation:
ERROR: exit status 254
I was able to make it work the following way (using the same proxy I created earlier):
$ AWS_ACCESS_KEY_ID=<generated_key> AWS_SECRET_ACCESS_KEY=<generated_secret> AWS_CA_BUNDLE=<path_to_pem>/aws-localca.pem aws ecs execute-command --cluster <cluster_name> --endpoint-url https://127.0.0.1:57090 --task <task_id> --interactive --command "/bin/bash"
It seems not to be the way it's supposed to work since I'm using the AWS CLI directly. Am I missing something?
edit: I'm using Teleport 13 now.
Teleport v13.0.3 git:v13.0.3-0-ge5db71f go1.20.4
Proxy version: 13.4.1
Hi @GlauberrBatista.
Sorry for the confusion. Could you try these out?
Alternative 1:
$ export NO_PROXY=ssmmessages.us-east-1.amazonaws.com
$ tsh aws ecs execute-command --cluster <cluster_name> --task $(tsh aws ecs list-tasks --cluster <cluster_name> --service-name <service_name> --output text --query "taskArns[0]") --interactive --command "/bin/bash"
Alternative 2:
$ tsh aws --endpoint-url -- ecs execute-command --cluster <cluster_name> --task $(tsh aws ecs list-tasks --cluster <cluster_name> --service-name <service_name> --output text --query "taskArns[0]") --interactive --command "/bin/bash"
Hi @greedy52,
Thank you for the response. It works both ways. Thank you very much! Is that documented elsewhere? I didn't check the documentation recently, but I don't recall seeing that anywhere.
I'm closing this issue now. 🙌
@GlauberrBatista
Thank you for the response. It works both ways. Thank you very much!
Awesome. For the first one (NO_PROXY
) you probably can just leave it in your bashrc and forget about it. But you would need more entries if pod is running in other regions.
I will make a fix to automatically do --endpoinit-url
when tsh
detects it's running tsh ecs execute-command
so you won't need any of these in the future. we did something similar for tsh aws ssm start-session
but missed this one.
I will update the document as well.
Thanks so much for reporting and trying things out. I will update this ticket when the fix is ready.
Expected behavior: To run
tsh aws ecs execute-command --cluster <cluster_name> --task $(tsh aws ecs list-tasks --cluster <cluster_name> --service-name <service_name> --output text --query "taskArns[0]") --interactive --command "/bin/bash"
and be able to open a SSM session inside a container on ECS.Current behavior:
Bug details:
Server logs