@@ -20,7 +20,7 @@ import * as semver from "semver"
20
20
import * as vscode from "vscode"
21
21
import * as ws from "ws"
22
22
import { SSHConfig , SSHValues , defaultSSHConfigResponse , mergeSSHConfigValues } from "./sshConfig"
23
- import { sshSupportsSetEnv } from "./sshSupport"
23
+ import { computeSSHProperties , sshSupportsSetEnv } from "./sshSupport"
24
24
import { Storage } from "./storage"
25
25
26
26
export class Remote {
@@ -411,7 +411,7 @@ export class Remote {
411
411
//
412
412
// If we didn't write to the SSH config file, connecting would fail with
413
413
// "Host not found".
414
- await this . updateSSHConfig ( )
414
+ await this . updateSSHConfig ( authorityParts [ 1 ] )
415
415
416
416
this . findSSHProcessID ( ) . then ( ( pid ) => {
417
417
if ( ! pid ) {
@@ -440,7 +440,7 @@ export class Remote {
440
440
441
441
// updateSSHConfig updates the SSH configuration with a wildcard that handles
442
442
// all Coder entries.
443
- private async updateSSHConfig ( ) {
443
+ private async updateSSHConfig ( hostName : string ) {
444
444
let deploymentSSHConfig = defaultSSHConfigResponse
445
445
try {
446
446
const deploymentConfig = await getDeploymentSSHConfig ( )
@@ -528,6 +528,34 @@ export class Remote {
528
528
}
529
529
530
530
await sshConfig . update ( sshValues , sshConfigOverrides )
531
+
532
+ // A user can provide a "Host *" entry in their SSH config to add options
533
+ // to all hosts. We need to ensure that the options we set are not
534
+ // overridden by the user's config.
535
+ const computedProperties = computeSSHProperties ( hostName , sshConfig . getRaw ( ) )
536
+ const keysToMatch : Array < keyof SSHValues > = [ "ProxyCommand" , "UserKnownHostsFile" , "StrictHostKeyChecking" ]
537
+ for ( let i = 0 ; i < keysToMatch . length ; i ++ ) {
538
+ const key = keysToMatch [ i ]
539
+ if ( computedProperties [ key ] === sshValues [ key ] ) {
540
+ continue
541
+ }
542
+
543
+ const result = await this . vscodeProposed . window . showErrorMessage (
544
+ "Unsupported SSH Config Option" ,
545
+ {
546
+ useCustom : true ,
547
+ modal : true ,
548
+ detail : `Your SSH config is overriding the "${ key } =${ computedProperties [ key ] } " option for the "${ hostName } " host. Please remove it and try again!` ,
549
+ } ,
550
+ "Reload Window" ,
551
+ )
552
+ if ( result === "Reload Window" ) {
553
+ await this . reloadWindow ( )
554
+ }
555
+ await this . closeRemote ( )
556
+ }
557
+
558
+ return sshConfig . getRaw ( )
531
559
}
532
560
533
561
// showNetworkUpdates finds the SSH process ID that is being used by this
0 commit comments