Skip to content

Use wildcard SSH host names #14986

Closed
Closed
@code-asher

Description

@code-asher

I would like to propose that we configure SSH with a wildcard instead of individual host names. For example:

coder.*
  ProxyCommand coder %h

And in ssh.go we trim out the coder. prefix.

Mainly, this is to support the IDEs. VS Code already does this with a special vscodessh sub-command but I think we should roll that up into ssh, then JetBrains can also benefit.

The main reason is that the IDEs support connecting to anyone's workspace (for admins). That means potentially hundreds of SSH config entries, and potentially hundreds of calls to template resources, since that has to be done for every workspace, at least the ones that are off, to get the agent names.

It would eventually remove the need for the Gateway and VS Code plugins to implement their own versions of config-ssh as they currently do, but this would need one more tweak to include the deployment URL in the host (for example coder-vscode.dev.coder.com--* is generated by the VS Code plugin).

It would eliminate the resource fetch loop in config-ssh as well.

As one data point, I tested with 138 off workspaces and configuring SSH took 20 seconds.

Alternatives:

  • A separate idessh sub-command that does this, maybe just rename vscodessh and add a deprecated alias, but I believe it also has some VS Code-specific logic that would need to be figured out.
  • Gate it behind flags (config-ssh --wildcard and ssh --wildcard or some such).
  • Skip changing config-ssh for now, and add ssh --strip-prefix=coder-vscode.dev.coder.com-- or some such flag to at least allow the IDEs to configure their own wildcard host.
  • From the IDEs, we could instead do some inline shell magic to strip out the prefix, but I am not sure what Windows support looks like.
coder-vscode.dev.coder.com--*
  ProxyCommand coder $(echo "%h" | sed 's/coder-vscode.dev.coder.com--//')

Edit: I presented the prefix flag as an alternative, but actually no matter what we will need a prefix flag for ssh because we want unique hosts for the plugins so they can add different SSH configuration if necessary (for example the session type env var, although that is deprecated). I also learned that config-ssh already has an ssh-prefix-host flag, so it makes sense to add that same flag to ssh. Then we can use ProxyCommand coder ssh --ssh-prefix-host coder-gateway.dev.coder.com. %h and emit a single wildcard entry in the plugins.

I think we should still eventually change config-ssh to use wildcards, and switch the plugins to use config-ssh instead of replicating that effort, but that can be done later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions