Skip to content

Conversation

@Liorba
Copy link

@Liorba Liorba commented Apr 5, 2023

coder's cli tool allow users to configure ssh conection to their remote hosts.
as part of it's configuration, he generate ssh config host to the dedicated user's machine.
The patten used by the cli tool, is not align with the one user by the vscode extension.
This mismatch between coder cli and the vscode extension, cause errors when trying to connect to remote host.

Key differences:

  1. the host pattern generated by the coder cli is coder.<workspace-name>.<agent>. currently the default agent is main
    the vscode extension is expecting the pattern coder-vscode--<workspace-owner>--<workspace-name>--<agent?>
  2. owner / user is not encoded in the ssh host name genereated by coder cli
  3. the cli allows the user to set different prefix other then coder

This PR is set to close the gap between the 2 and make sure hosts created by the cli can be connected from the vscode extension

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Liorba, I'm a bit confused by this contribution. We don't want coder config-ssh to interact with the VS Code extension at all, because they are truly separate experiences.

Could you explain more of the problem this solves?

// when opening a workspace unless explicitly specified.
const remoteAuthority = `ssh-remote+${Remote.Prefix}${workspaceOwner}--${workspaceName}`
// search for workspace name in the ssh config
const remoteAuthority = `ssh-remote+${Remote.Prefix}.${workspaceName}.main` //main is the default agent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main is not the default name for an agent. It can be anything that a user defines!

Comment on lines +43 to +45
// if (!authorityParts[1].startsWith(Remote.Prefix)) {
// return
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be checked, otherwise Coder will activate on any remote SSH connection, which will cause errors to appear on non-Coder connections.

@Liorba
Copy link
Author

Liorba commented Apr 5, 2023

The reason for that is the ability to use the vscode extension to connect to workspaces that was configured using the config ssh option.
For example. I have a workspace that I'm connected to using ssh that I already configured via the cli.
I want to seamlessly be able to connect to it and work.with it using the extension.

@Emyrk
Copy link
Member

Emyrk commented Apr 6, 2023

The reason for that is the ability to use the vscode extension to connect to workspaces that was configured using the config ssh option. For example. I have a workspace that I'm connected to using ssh that I already configured via the cli. I want to seamlessly be able to connect to it and work.with it using the extension.

Currently as Kyle mentioned, the cli and the vscode extension are intentionally writing different ssh config blocks. These blocks should never be written to by the user, and if custom options are needed, there is flags on the cli and extension settings in the extension to add/remove ssh config options.

Keeping these distinct from each other means we can define custom behavior of the ssh, which is currently just SetEnv CODER_SSH_SESSION_TYPE=vscode. This custom behavior is how we can keep track of what type of connection is being made to the agent.


The reason for that is the ability to use the vscode extension to connect to workspaces that was configured using the config ssh option.

In the extension, do you not just select a workspace? You do not select from a set of configured ssh hosts. You choose the workspace itself. So the ssh config logic is never exposed to the user.

Screenshot from 2023-04-06 09-00-53

If you are using VSCode-Remote instead, and selecting the ssh host, then you are not using the Coder extension. In that case, you can select any config-ssh host you would like from either configuration block.

Screenshot from 2023-04-06 09-01-56


I am curious what your workflow is that the two different ssh host namings are being presented to the user.

@code-asher code-asher force-pushed the main branch 4 times, most recently from 009bca7 to bcf5486 Compare June 21, 2024 23:50
@code-asher code-asher force-pushed the main branch 2 times, most recently from 05e11c3 to d18614d Compare July 1, 2024 20:32
@code-asher
Copy link
Member

code-asher commented Oct 31, 2024

Closing as stale, but happy to reopen and take another look if this becomes active again.

@code-asher code-asher closed this Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants