@@ -43,6 +43,7 @@ export interface IRemoteService {
43
43
getWorkspaceSSHDestination ( wsData : WorkspaceData ) : Promise < { destination : SSHDestination ; password ?: string } > ;
44
44
showSSHPasswordModal ( wsData : WorkspaceData , password : string ) : Promise < void > ;
45
45
46
+ updateRemoteSSHConfig ( usingSSHGateway : boolean , localAppSSHConfigPath : string | undefined ) : Promise < void > ;
46
47
initializeRemoteExtensions ( ) : Promise < void > ;
47
48
}
48
49
@@ -177,11 +178,12 @@ export class RemoteService extends Disposable implements IRemoteService {
177
178
await SSHConfiguration . saveGitpodSSHConfig ( gitpodConfig ) ;
178
179
}
179
180
180
- private getHostSSHConfig ( host : string , launcher : string , proxyScript : string , extIpcPort : number , logLevel :string ) {
181
+ private getHostSSHConfig ( host : string , launcher : string , proxyScript : string , extIpcPort : number , logLevel : string ) {
182
+ const extraArgs = ( process . versions [ 'electron' ] && process . versions [ 'microsoft-build' ] ) ? '--ms-enable-electron-run-as-node' : '' ;
181
183
return {
182
184
Host : '*.' + getLocalSSHDomain ( host ) ,
183
185
StrictHostKeyChecking : 'no' ,
184
- ProxyCommand : `"${ launcher } " "${ process . execPath } " "${ proxyScript } " --ms-enable-electron-run-as-node %h ${ extIpcPort } ${ vscode . env . machineId } ${ logLevel } `
186
+ ProxyCommand : `"${ launcher } " "${ process . execPath } " "${ proxyScript } " ${ extraArgs } %h ${ extIpcPort } ${ vscode . env . machineId } ${ logLevel } `
185
187
} ;
186
188
}
187
189
@@ -326,6 +328,30 @@ export class RemoteService extends Disposable implements IRemoteService {
326
328
throw new Error ( 'SSH password modal dialog, Canceled' ) ;
327
329
}
328
330
331
+ async updateRemoteSSHConfig ( usingSSHGateway : boolean , localAppSSHConfigPath : string | undefined ) {
332
+ const remoteSSHconfig = vscode . workspace . getConfiguration ( 'remote.SSH' ) ;
333
+ const defaultExtConfigInfo = remoteSSHconfig . inspect < string [ ] > ( 'defaultExtensions' ) ;
334
+ const defaultExtensions = defaultExtConfigInfo ?. globalValue ?? [ ] ;
335
+ if ( ! defaultExtensions . includes ( 'gitpod.gitpod-remote-ssh' ) ) {
336
+ defaultExtensions . unshift ( 'gitpod.gitpod-remote-ssh' ) ;
337
+ await remoteSSHconfig . update ( 'defaultExtensions' , defaultExtensions , vscode . ConfigurationTarget . Global ) ;
338
+ }
339
+
340
+ const currentConfigFile = remoteSSHconfig . get < string > ( 'configFile' ) ;
341
+ if ( usingSSHGateway ) {
342
+ if ( currentConfigFile ?. includes ( 'gitpod_ssh_config' ) ) {
343
+ await remoteSSHconfig . update ( 'configFile' , undefined , vscode . ConfigurationTarget . Global ) ;
344
+ }
345
+ } else {
346
+ // TODO(ak) notify a user about config file changes?
347
+ if ( currentConfigFile === localAppSSHConfigPath ) {
348
+ // invalidate cached SSH targets from the current config file
349
+ await remoteSSHconfig . update ( 'configFile' , undefined , vscode . ConfigurationTarget . Global ) ;
350
+ }
351
+ await remoteSSHconfig . update ( 'configFile' , localAppSSHConfigPath , vscode . ConfigurationTarget . Global ) ;
352
+ }
353
+ }
354
+
329
355
async initializeRemoteExtensions ( ) {
330
356
let flowData = this . flow ?? { gitpodHost : this . hostService . gitpodHost , userId : this . sessionService . safeGetUserId ( ) } ;
331
357
flowData = { ...flowData , flow : 'sync_local_extensions' , useLocalAPP : String ( Configuration . getUseLocalApp ( ) ) } ;
0 commit comments