Description
An SSH config can be written such that all connections to workspaces using the Coder VS Code hostname also run a RemoteCommand
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 -l
This works fine with OpenSSH in /usr/bin/ssh
:
$ ssh coder-vscode.example.coder.com--ethan--dev
test
coder@dev $
However, there's a comment on remote.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 of remote.SSH.EnableRemoteCommand
.)
What appears to be breaking RemoteCommand
is whether the host being connected to has a platform specified in remote.SSH.RemotePlatform
.
If I have, in my settings.json
:
"remote.SSH.remotePlatform": {"coder-vscode.example.coder.com--ethan--dev":"linux"}
and a RemoteCommand
(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 that remotePlatform
entry, bash
is removed from that ssh
command string, and you're able to connect, and the RemoteCommand
is ran.
However, our VS Code extension creates this remotePlatform
entry if it doesn't exist, each time a workspace is connected to:
Lines 445 to 463 in e0adfb8
This makes it impossible to connect to a workspace via the Coder VS Code extension if a RemoteCommand
option is set on the host config.
This issue can be worked around by bypassing the Coder VS Code extension, and instead connecting to workspace.coder
in Remote - SSH
after having run coder config-ssh
, and ensuring there's no entry for workspace.coder
in remote.SSH.remotePlatform
.