Skip to content

Use motd for all output in coder ssh [--stdio] commands  #4927

@mafredri

Description

@mafredri

We have multiple scenarios in which we print output during SSH commands (both ssh coder... and coder ssh ...):

This is not ideal since we must not get in the way of using SSH normally. Things like:

out=$(ssh coder.workspace ls)
err=$(ssh coder.workspace ls 2>&1 1>/dev/null)

should work without dirtying the output.

The ideal way to do this would be to utilize motd for all SSH messaging. This would, however, mean that messages are delayed until connection is established. Which would be problematic if we want to inform the users that the cli version is mismatched and we can't establish a connection because of it.

Ultimately we may want to have both methods, reserving the non-motd output for critical messages.

At minimum, we should comb over how we are printing these messages and ensure they’re hidden in non-tty cases.

Edit: This issue was originally created with the incorrect assumption that banner translates to motd, banner is in fact the message shown before authentication, motd is shown just before the login shell.


I think printing to stderr is a good first step, but in the future I think it would be a good idea to start using BannerCallback instead.

At least on systems with /etc/motd and OpenSSH, messages don't appear in non-interactive modes like ssh host ls. I believe this should (automatically) be the case when using BannerCallback too.

But to do that, we'd also need to fix all other occurrences of printing to stdout in the coder ssh [--stdio] command.

Originally posted by @mafredri in #4926 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions