Skip to content

Automatically update coder SSH config on coder create and coder delete #2153

Closed as not planned
@mafredri

Description

@mafredri

Feature request

It would be nice if we could automatically update coder SSH config on coder create and coder delete.

With #1900 merged, the coder SSH config is now a separate file we can safely edit without causing trouble for the user (~/.ssh/coder).

Why is this useful?

  • It removes an extra step, the user only needs to run coder config-ssh once
  • After coder create the workspace automatically will show up in e.g. vscode remote explorer

Potential problems

  • Simultaneous writes to ~/.ssh/coder from multiple coder instances (rare edge case)

To work around the simultaneous write, we can grab a flock on the file, fetch the most recent workspaces, write, release flock. This will work as a kind of mutex ensuring each separate process only writes the latest workspaces to the file.

Can we do this by only using glob-hosts in ~/.ssh/coder?

No.

Using a glob host in ~/.ssh/coder would allow for ssh coder.workspace to work without any additional updates to the config:

Host coder.*
	...

However, this does not allow tools like VSCode Remote Explorer to detect the hostnames/workspaces, nor does it work for shell autocomplete. So even if we use globs or not, we will want to write the actual workspaces to the config.

There's also a small risk of matching valid domain names, like ssh coder.[TLD] where TLD is a valid top-level domain like .work, .edu, .jobs, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiArea: HTTP APIcliArea: CLIsiteArea: frontend dashboard

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions