Skip to content

Refactor SSH prefix into a workspace suffix #16828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ThomasK33 opened this issue Mar 6, 2025 · 3 comments · Fixed by #17445
Closed

Refactor SSH prefix into a workspace suffix #16828

ThomasK33 opened this issue Mar 6, 2025 · 3 comments · Fixed by #17445
Assignees

Comments

@ThomasK33
Copy link
Member

ThomasK33 commented Mar 6, 2025

To implement one-click buttons for native applications in Coder Desktop, we need to refactor how (SSH) hostnames are handled⁠.

Currently, Coder uses a hostname prefix for SSH configuration, but this approach is incompatible with Coder Desktop which requires a suffix-based approach. This refactoring is necessary to enable seamless deep linking and native application launches⁠⁠.

Tasks include:

  • Deprecate the existing hostname prefix option⁠⁠
  • Implement a new hostname suffix option to be used by the config-ssh command and Coder Desktop (e.g., HostnameSuffix, defaulting to coder)⁠
  • Update the config-ssh subcommand to reflect these changes⁠⁠
  • Dynamically configure VPN DNS settings & workspace hostnames based on the hostname suffix
bpmct added a commit that referenced this issue Mar 6, 2025
This change modifies the SSH hostname pattern to use a suffix-based approach instead of a prefix.
It adds a new --ssh-hostname-suffix flag to replace the old --ssh-hostname-prefix, supporting
domain-based hostnames like 'workspace.coder' instead of 'coder.workspace'.

The changes:
- Add HostnameSuffix field to SSHConfig and SSHConfigResponse structs
- Deprecate the existing hostname prefix option
- Implement suffix-based hostname parsing in SSH command
- Update VPN DNS to use the hostname suffix
- Use the suffix in tailnet/vpn for DNS configuration

This refactoring is necessary to support one-click buttons for native applications in
Coder Desktop, which requires a suffix-based approach for deep linking and native application
launches.

Fixes #16828
@aaronlehmann
Copy link
Contributor

Are you planning to change the IDE plugins to use a suffix rather than a prefix?

@ThomasK33
Copy link
Member Author

Are you planning to change the IDE plugins to use a suffix rather than a prefix?

Hey @aaronlehmann 👋 , yes, we will update the plugins to use the suffix and make them aware of the existing Coder Desktop tunnel.

Just a heads up, those changes will come in a later phase, so keep an eye on the parent issue (phase 1) for more info.

bpmct added a commit that referenced this issue Mar 10, 2025
Add support for base_image parameter to Docker template as per issue #16828.
This allows specifying both the final container image and base image used for building.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
@deansheather
Copy link
Member

Since this needs to be used by the UI, the extensions and the desktop apps, it will most likely need to be a server-side option for consistency

@spikecurtis spikecurtis self-assigned this Apr 4, 2025
spikecurtis added a commit that referenced this issue Apr 7, 2025
Adds `hostname-suffix` flag to `coder ssh` command for use in SSH Config ProxyCommands.

Also enforces that Coder server doesn't start the suffix with a dot.

part of: #16828
spikecurtis added a commit that referenced this issue Apr 8, 2025
Wires up `config-ssh` command to use a hostname suffix if configured.

part of: #16828


e.g. `coder config-ssh --hostname-suffix spiketest` gives:

```
# ------------START-CODER-----------
# This section is managed by coder. DO NOT EDIT.
#
# You should not hand-edit this section unless you are removing it, all
# changes will be lost when running "coder config-ssh".
#
# Last config-ssh options:
# :hostname-suffix=spiketest
#
Host coder.* *.spiketest
        ConnectTimeout=0
        StrictHostKeyChecking=no
        UserKnownHostsFile=/dev/null
        LogLevel ERROR
        ProxyCommand /home/coder/repos/coder/build/coder_config_ssh --global-config /home/coder/.config/coderv2 ssh --stdio --ssh-host-prefix coder. --hostname-suffix spiketest %h
# ------------END-CODER------------
```
spikecurtis added a commit that referenced this issue Apr 11, 2025
Adds the Hostname Suffix to `AgentConnectionInfo` --- the VPN provider will use it to control the suffix for DNS hostnames.

part of: #16828
spikecurtis added a commit that referenced this issue Apr 11, 2025
Use the hostname suffix to set DNS names as programmed into the DNS service and returned by the vpn `Tunnel`.

part of: #16828
spikecurtis added a commit that referenced this issue Apr 11, 2025
Use the hostname suffix to set the DNS match domain when creating a Tailnet as part of the vpn `Tunnel`.

part of: #16828
spikecurtis added a commit that referenced this issue Apr 14, 2025
Adds `IsCoderConnectRunning()` to the workspacesdk. This will support the `coder` CLI being able to use CoderConnect when it's running.

part of #16828
spikecurtis added a commit that referenced this issue Apr 17, 2025
relates to #16828

Changes SSH config so that suffixes only match if Coder Connect is not running / available. This means that we will use the existing Coder Connect tunnel if it is available, rather than creating a new tunnel via `coder ssh --stdio`.
spikecurtis added a commit that referenced this issue Apr 17, 2025
fixes #16828

With all the recent changes, I believe it is now safe to change the Call to Action for `config-ssh` to use the hostname suffix rather than prefix if it was set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment