6

I am attempting to gain shell level access from a windows machine to a Linux ECS Task in an AWS Fargate Cluster via the AWS CLI (v2.1.38) through aws-vault.

The redacted command I am using is

aws-vault exec my-profile -- aws ecs execute-command --cluster my-cluster-name --task my-task-id --interactive --command "/bin/sh"

but this fails with this output

The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.
Starting session with SessionId: ecs-execute-command-0bc2d48dbb164e010
SessionId: ecs-execute-command-0bc2d48dbb164e010 :
----------ERROR-------
Unable to start shell: Failed to start pty: fork/exec C:/Program: no such file or directory

I can see that ECS Exec is enabled on this task because an aws describe shows the following. enter image description here

It appears that its recognising the host is a windows machine and attempting to initialise based on a variable that is windows specific.

Is anyone able to suggest what I can do to resolve this.

chrisp_68
  • 1,731
  • 23
  • 41
  • I would have loved to use https://github.com/tedsmitt/ecsgo but its not available on windows yet. – chrisp_68 Apr 22 '21 at 13:44
  • 2
    I've been unable to get the ECS exec command to run from a Windows command prompt or a GitBash command prompt. If you switch over to an Ubuntu command prompt in WSL2 it will work fine. – Mark B Apr 22 '21 at 15:14
  • Hi @MarkB Thanks for the input, that has worked a treat. – chrisp_68 Apr 26 '21 at 16:36

4 Answers4

8

Ran into the same error. Using --command "bash" worked for me on Windows 10.

rchang
  • 81
  • 1
  • 2
1

I was using windows 7, I think without WSL (Windows 10+) or Linux (or Mac) it just doesn't work. There's another suggestion explained here that's not worth the trouble:

Cannot start an AWS ssm session on EC2 Amazon linux instance

For me, I just used a Linux bastion inside AWS and it worked from there.

Trent
  • 51
  • 2
1

Ran into a similar issue. Not all docker containers required bash. Try using:

--command "sh"
0

Using a windows powershell to run this command worked for me

Nithu
  • 83
  • 1
  • 6