aws start-session end with **Cannot perform start session: EOF**
Asked Answered
L

2

6

I try to using Session Manager within my CI (with a vanilla configuration, so nothing too fancy).

All inputs (keys, etc.) and configurations (user/strategy/key) are valid. I succeed to start a session on my own laptop.

But on my pipeline i got the following message

Starting session with SessionId: xxxx-xxxxxxx
$ **Cannot perform start session: EOF**

Is this shell related ?

For reference, tools used on the CI :

  • Session Manager plugin : 1.2.30.0
  • AWS CLI : aws-cli/1.18.223 Python/2.7.17 Linux/5.4.0-1039-azure botocore/1.19.63
Lollis answered 5/2, 2021 at 16:16 Comment(4)
Did you figure out the solution? I'm having the same issue. My case is I'm running aws ecs execute-command from github action.Mesozoic
@BenjaminHao Yes, it's simply related to TTY. At the end we reserved start-session for SSHing through laptops. For our CD we're using aws ssm send-command --document-name "AWS-RunShellScript" and a script executed remotly (on EC2 on our case, not ECS). RegardsLollis
Thanks! I will try your solution. I found another one that worked for me. I installed expect by sudo apt-get install expect and run the command using unbuffer aws ecs execute-command .... Mesozoic
@BenjaminHao It's clever, since unbuffer allow to bypass the interactive behavior ;)Lollis
B
9

If you bumped into this error like I did:

Cannot perform start session: EOF

and got here, then using the information from Benjamin Hao's comment, here are the steps I took to make it finally work:

Install expect, in my case I had to install it on the Github hosted runner which is installed with Ubuntu:

apt install -y expect

Then, add "unbuffer" before the command you're trying to execute, for example:

unbuffer aws ecs execute-command --region $REGION --cluster $ecs_cluster_name --task $ecs_task_id --container ops-machine --command 'clitool env start --confirm' --interactive
Bartonbartosch answered 3/4, 2022 at 16:53 Comment(1)
This issue posted with SSM coves this as well.Seamus
P
0

For aws ssm command i used the AWS-StartInteractiveCommand option in --document-name

aws ssm start-session --document-name 'AWS-StartInteractiveCommand' --parameters '{"command": ["some_command"]}' --target ${ec2_instance_id}

With this, you don't need to install expect

Pearlene answered 5/12, 2023 at 19:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.