- Notifications
You must be signed in to change notification settings - Fork35
Description
An SSH config can be written such that all connections to workspaces using the Coder VS Code hostname also run aRemoteCommand when connecting:
# --- START CODER VSCODE example.coder.com ---Host coder-vscode.example.coder.com--* ConnectTimeout 0 LogLevel ERROR ProxyCommand "/path/to/coder ssh [....] %h" SetEnv CODER_SSH_SESSION_TYPE=vscode StrictHostKeyChecking no UserKnownHostsFile /dev/null# --- END CODER VSCODE example.coder.com ---Host coder-vscode.example.coder.com--* RequestTTY yes RemoteCommand echo "test"; exec /bin/bash -lThis works fine with OpenSSH in/usr/bin/ssh:
$ ssh coder-vscode.example.coder.com--ethan--devtestcoder@dev $However, there's a comment onremote.SSH.EnableRemoteCommand that says:
Experimental: Enable using RemoteCommands from ssh config entries. This is only enabled if #remote.SSH.useLocalServer# is enabled as well and the remote you are trying to connect to is not listed under the #remote.SSH.remotePlatform# setting.
(From my, and the customer's, testing,RemoteCommand seems to work regardless of the value ofremote.SSH.EnableRemoteCommand.)
What appears to be breakingRemoteCommand is whether the host being connected to has a platform specified inremote.SSH.RemotePlatform.
If I have, in mysettings.json:
"remote.SSH.remotePlatform": {"coder-vscode.example.coder.com--ethan--dev":"linux"}and aRemoteCommand (as above), VS Code fails to connect to the workspace:
Running ssh connection command: ssh -v -T -D 55444 -o ConnectTimeout=1800 coder-vscode.example.coder.com--ethan--dev bash
Cannot execute command-line and remote command.
If I remove thatremotePlatform entry,bash is removed from thatssh command string, and you're able to connect, and theRemoteCommand is ran.
However, our VS Code extensioncreates thisremotePlatform entry if it doesn't exist, each time a workspace is connected to:
Lines 445 to 463 ine0adfb8
| // Add the remote platform for this host to bypass a step where VS Code asks | |
| // the user for the platform. | |
| letmungedPlatforms=false; | |
| if( | |
| !remotePlatforms[parts.host]|| | |
| remotePlatforms[parts.host]!==agent.operating_system | |
| ){ | |
| remotePlatforms[parts.host]=agent.operating_system; | |
| settingsContent=jsonc.applyEdits( | |
| settingsContent, | |
| jsonc.modify( | |
| settingsContent, | |
| ["remote.SSH.remotePlatform"], | |
| remotePlatforms, | |
| {}, | |
| ), | |
| ); | |
| mungedPlatforms=true; | |
| } |
This makes it impossible to connect to a workspacevia the Coder VS Code extension if aRemoteCommand option is set on the host config.
This issue can be worked around by bypassing the Coder VS Code extension, and instead connecting toworkspace.coder inRemote - SSH after having runcoder config-ssh, and ensuring there's no entry forworkspace.coder inremote.SSH.remotePlatform.