diff --git a/src/commands/workspaces.ts b/src/commands/workspaces.ts index 17a1045..e9b85d7 100644 --- a/src/commands/workspaces.ts +++ b/src/commands/workspaces.ts @@ -350,6 +350,7 @@ export class ConnectInCurrentWindowCommand implements Command { private async initializeLocalSSH(workspaceId: string) { try { + await this.remoteService.updateRemoteSSHConfig(true, undefined); await Promise.all([ this.remoteService.setupSSHProxy(), this.remoteService.startLocalSSHServiceServer() diff --git a/src/remoteConnector.ts b/src/remoteConnector.ts index 908c70c..34d54ef 100644 --- a/src/remoteConnector.ts +++ b/src/remoteConnector.ts @@ -580,31 +580,12 @@ export class RemoteConnector extends Disposable { }); } - private async updateRemoteSSHConfig(usingSSHGateway: boolean, localAppSSHConfigPath: string | undefined) { - const remoteSSHconfig = vscode.workspace.getConfiguration('remote.SSH'); - const defaultExtConfigInfo = remoteSSHconfig.inspect('defaultExtensions'); - const defaultExtensions = defaultExtConfigInfo?.globalValue ?? []; - if (!defaultExtensions.includes('gitpod.gitpod-remote-ssh')) { - defaultExtensions.unshift('gitpod.gitpod-remote-ssh'); - await remoteSSHconfig.update('defaultExtensions', defaultExtensions, vscode.ConfigurationTarget.Global); - } - - const currentConfigFile = remoteSSHconfig.get('configFile'); - if (usingSSHGateway) { - if (currentConfigFile?.includes('gitpod_ssh_config')) { - await remoteSSHconfig.update('configFile', undefined, vscode.ConfigurationTarget.Global); - } - } else { - // TODO(ak) notify a user about config file changes? - if (currentConfigFile === localAppSSHConfigPath) { - // invalidate cached SSH targets from the current config file - await remoteSSHconfig.update('configFile', undefined, vscode.ConfigurationTarget.Global); - } - await remoteSSHconfig.update('configFile', localAppSSHConfigPath, vscode.ConfigurationTarget.Global); + private async ensureRemoteSSHExtInstalled(flow: UserFlowTelemetryProperties): Promise { + const isOfficialVscode = vscode.env.uriScheme === 'vscode' || vscode.env.uriScheme === 'vscode-insiders'; + if (!isOfficialVscode) { + return true; } - } - private async ensureRemoteSSHExtInstalled(flow: UserFlowTelemetryProperties): Promise { const msVscodeRemoteExt = vscode.extensions.getExtension('ms-vscode-remote.remote-ssh'); if (msVscodeRemoteExt) { return true; @@ -704,7 +685,7 @@ export class RemoteConnector extends Disposable { try { this.telemetryService.sendUserFlowStatus('connecting', localSSHFlow); // If needed, revert local-app changes first - await this.updateRemoteSSHConfig(true, undefined); + await this.remoteService.updateRemoteSSHConfig(true, undefined); this.remoteService.flow = sshFlow; await Promise.all([ @@ -834,7 +815,7 @@ export class RemoteConnector extends Disposable { } } - await this.updateRemoteSSHConfig(usingSSHGateway, localAppSSHConfigPath); + await this.remoteService.updateRemoteSSHConfig(usingSSHGateway, localAppSSHConfigPath); await this.context.globalState.update(`${SSH_DEST_KEY}${sshDestination!.toRemoteSSHString()}`, { ...params } as SSHConnectionParams); diff --git a/src/services/remoteService.ts b/src/services/remoteService.ts index 717b170..dbc4531 100644 --- a/src/services/remoteService.ts +++ b/src/services/remoteService.ts @@ -43,6 +43,7 @@ export interface IRemoteService { getWorkspaceSSHDestination(wsData: WorkspaceData): Promise<{ destination: SSHDestination; password?: string }>; showSSHPasswordModal(wsData: WorkspaceData, password: string): Promise; + updateRemoteSSHConfig(usingSSHGateway: boolean, localAppSSHConfigPath: string | undefined): Promise; initializeRemoteExtensions(): Promise; } @@ -177,11 +178,12 @@ export class RemoteService extends Disposable implements IRemoteService { await SSHConfiguration.saveGitpodSSHConfig(gitpodConfig); } - private getHostSSHConfig(host: string, launcher: string, proxyScript: string, extIpcPort: number, logLevel:string) { + private getHostSSHConfig(host: string, launcher: string, proxyScript: string, extIpcPort: number, logLevel: string) { + const extraArgs = (process.versions['electron'] && process.versions['microsoft-build']) ? '--ms-enable-electron-run-as-node' : ''; return { Host: '*.' + getLocalSSHDomain(host), StrictHostKeyChecking: 'no', - ProxyCommand: `"${launcher}" "${process.execPath}" "${proxyScript}" --ms-enable-electron-run-as-node %h ${extIpcPort} ${vscode.env.machineId} ${logLevel}` + ProxyCommand: `"${launcher}" "${process.execPath}" "${proxyScript}" ${extraArgs} %h ${extIpcPort} ${vscode.env.machineId} ${logLevel}` }; } @@ -326,6 +328,30 @@ export class RemoteService extends Disposable implements IRemoteService { throw new Error('SSH password modal dialog, Canceled'); } + async updateRemoteSSHConfig(usingSSHGateway: boolean, localAppSSHConfigPath: string | undefined) { + const remoteSSHconfig = vscode.workspace.getConfiguration('remote.SSH'); + const defaultExtConfigInfo = remoteSSHconfig.inspect('defaultExtensions'); + const defaultExtensions = defaultExtConfigInfo?.globalValue ?? []; + if (!defaultExtensions.includes('gitpod.gitpod-remote-ssh')) { + defaultExtensions.unshift('gitpod.gitpod-remote-ssh'); + await remoteSSHconfig.update('defaultExtensions', defaultExtensions, vscode.ConfigurationTarget.Global); + } + + const currentConfigFile = remoteSSHconfig.get('configFile'); + if (usingSSHGateway) { + if (currentConfigFile?.includes('gitpod_ssh_config')) { + await remoteSSHconfig.update('configFile', undefined, vscode.ConfigurationTarget.Global); + } + } else { + // TODO(ak) notify a user about config file changes? + if (currentConfigFile === localAppSSHConfigPath) { + // invalidate cached SSH targets from the current config file + await remoteSSHconfig.update('configFile', undefined, vscode.ConfigurationTarget.Global); + } + await remoteSSHconfig.update('configFile', localAppSSHConfigPath, vscode.ConfigurationTarget.Global); + } + } + async initializeRemoteExtensions() { let flowData = this.flow ?? { gitpodHost: this.hostService.gitpodHost, userId: this.sessionService.safeGetUserId() }; flowData = { ...flowData, flow: 'sync_local_extensions', useLocalAPP: String(Configuration.getUseLocalApp()) };