amazon-ssm-agent icon indicating copy to clipboard operation
amazon-ssm-agent copied to clipboard

SSM and xterm issues with zsh

Open altjx opened this issue 4 years ago • 5 comments

I have spent quite some time today trying to figure out why my tmux sessions look perfectly fine via SSH compared to when I'm connected to a server via SSM.

For example:

image

This happens with any command that has a pretty extensive output.

As you can see, the tmux panes bleed over. I figured out that it was due to the TERM environment variable. From the SSH session, it was set to xterm-256color and it worked just fine. From the prompt (after connecting via SSM), it was also the same but the tmux session was different.

When I changed this value to ansi it fixed my problem.

However, I'm now having the same issue in docker and I can't set the TERM to ansi because of some other issues. Not sure if there's anything I can "configure" per se, but just wanted to check to see if there's another way I could resolve this issue.

altjx avatar Jan 17 '21 03:01 altjx

Hello! Thank you for your post. You are correct in that the normal way of altering the output of the terminal is through modifying the TERM variable. We are actively investigating other methods for altering the output outside of changing the term variable. We were able to reproduce your issue with some commands, such as the 'help' command, but saw that other commands had the correct text wrapping to display all the output correctly. For your issue, is this output truncation issue something that occurs for all long output or specific commands?

One way of preserving your output is to send output to an s3 bucket via the Session Manager preferences. With ECS, you can configure the ecs task role to allow output to be sent to an s3 bucket. You can see the directions for that here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html With normal ec2 instances, you can also configure the instance role to have s3 permissions. You can see the directions for that here: https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-logging.html

fmiao1618 avatar Apr 26 '21 19:04 fmiao1618

Thanks for your comment @fmiao1618.

For those who may be looking to do this in a more automated, convenient way, just add this to the SSM preferences so that this run on every SSM agent connect:

export LANG=en_US.UTF-8; export TERM=ansi

altjx avatar May 18 '21 20:05 altjx

Hello! Session Manager by default sets xterm-256color as the TERM variable for shell sessions. To change this value, you can either directly alter it in the shell session or set it in the shell profile to change it automatically when you start a session.

fmiao1618 avatar May 20 '21 21:05 fmiao1618

Related:

  • https://github.com/aws/session-manager-plugin/issues/29
  • https://github.com/aws/session-manager-plugin/issues/28

justinmk3 avatar Dec 29 '21 13:12 justinmk3

Problem with TERM=ansi is that mouse mode does not work.

kdesjard avatar Nov 14 '22 20:11 kdesjard