Skip to content

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

Closed as not planned

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)

Activity

  1. bpmct commented on Nov 7, 2022

    @bpmct
    Member

    Is /etc/motd used in terminals on VS Code Remote SSH? A large amount our users connect exclusively through this.

  2. mafredri commented on Nov 8, 2022

    @mafredri
    MemberAuthor

    Is /etc/motd used in terminals on VS Code Remote SSH? A large amount our users connect exclusively through this.

    @bpmct As @mtojek found out, this does not seem to be the case.

    The best way to support this would be via VSCode extension. I think it should be fairly easy to detect that this is a Remote SSH connection to a Coder workspace (one option is to check env CODER=true), check workspace status and surface a notification. It could be part of #3597.

    We could potentially add a new env to workspaces as well, CODER_WORKSPACE_OUTDATED=true. I can think of a few cool uses but mostly it's "yet another way to detect a workspace is outdated" (YAWTDAWIO?).

  3. changed the title [-]Use motd (`BannerCallback`) for all output in `coder ssh [--stdio]` commands [/-] [+]Use motd for all output in `coder ssh [--stdio]` commands [/+] on Nov 16, 2022
  4. github-actions commented on Jan 16, 2023

    @github-actions
    Contributor

    This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity.

  5. github-actions commented on Apr 24, 2023

    @github-actions
    Contributor

    This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity.

  6. mafredri commented on Dec 16, 2023

    @mafredri
    MemberAuthor

    the ssh nag is presenting a problem for someone. they have a local command aliased to ssh into their workspace and run the same command. when he uses tab to autocomplete the parameters the result is:

    $ ffs ls /👋 Your workspace is outdated! Update it here: …
    

    should that message be printing if its a non-interactive session? could there be flags in coder ssh to disable it to prevent

    A customer is running into this issue, a non-interactive session should not dirty the output.

  7. sreya commented on Apr 4, 2024

    @sreya
    Collaborator

    Feel free to reopen if this is still a priority

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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