@@ -26,7 +26,7 @@ import { createBoundProcess } from '../codecatalyst/model'
26
26
import { getLogger } from '../shared/logger/logger'
27
27
import { Timeout } from '../shared/utilities/timeoutUtils'
28
28
import { showMessageWithCancel } from '../shared/utilities/messages'
29
- import { VscodeRemoteSshConfig , sshLogFileLocation } from '../shared/vscodeRemoteSshConfig '
29
+ import { SshConfig , sshLogFileLocation } from '../shared/sshConfig '
30
30
import { SshKeyPair } from './sshKeyPair'
31
31
import globals from '../shared/extensionGlobals'
32
32
@@ -36,9 +36,6 @@ interface Ec2RemoteEnv extends VscodeRemoteConnection {
36
36
selection : Ec2Selection
37
37
}
38
38
39
- const ec2ConnectScriptPrefix = 'ec2_connect'
40
- const hostNamePrefix = 'ec2-'
41
-
42
39
export class Ec2ConnectionManager {
43
40
protected ssmClient : SsmClient
44
41
protected ec2Client : Ec2Client
@@ -177,15 +174,14 @@ export class Ec2ConnectionManager {
177
174
}
178
175
}
179
176
180
- public async attemptToOpenRemoteConnection ( selection : Ec2Selection ) : Promise < void > {
177
+ public async tryOpenRemoteConnection ( selection : Ec2Selection ) : Promise < void > {
181
178
await this . checkForStartSessionError ( selection )
182
179
183
180
const remoteUser = await this . getRemoteUser ( selection . instanceId )
184
181
const remoteEnv = await this . prepareEc2RemoteEnvWithProgress ( selection , remoteUser )
185
182
186
- const fullHostName = `${ hostNamePrefix } ${ selection . instanceId } `
187
183
try {
188
- await startVscodeRemote ( remoteEnv . SessionProcess , fullHostName , '/' , remoteEnv . vscPath , remoteUser )
184
+ await startVscodeRemote ( remoteEnv . SessionProcess , remoteEnv . hostname , '/' , remoteEnv . vscPath , remoteUser )
189
185
} catch ( err ) {
190
186
this . throwGeneralConnectionError ( selection , err as Error )
191
187
}
@@ -202,7 +198,8 @@ export class Ec2ConnectionManager {
202
198
const logger = this . configureRemoteConnectionLogger ( selection . instanceId )
203
199
const { ssm, vsc, ssh } = ( await ensureDependencies ( ) ) . unwrap ( )
204
200
const keyPath = await this . configureSshKeys ( selection , remoteUser )
205
- const sshConfig = new VscodeRemoteSshConfig ( ssh , hostNamePrefix , ec2ConnectScriptPrefix , keyPath )
201
+ const hostNamePrefix = 'aws-ec2-'
202
+ const sshConfig = new SshConfig ( ssh , hostNamePrefix , 'ec2_connect' , keyPath )
206
203
207
204
const config = await sshConfig . ensureValid ( )
208
205
if ( config . isErr ( ) ) {
@@ -223,7 +220,7 @@ export class Ec2ConnectionManager {
223
220
} )
224
221
225
222
return {
226
- hostname : selection . instanceId ,
223
+ hostname : ` ${ hostNamePrefix } ${ selection . instanceId } ` ,
227
224
envProvider,
228
225
sshPath : ssh ,
229
226
vscPath : vsc ,
@@ -250,10 +247,10 @@ export class Ec2ConnectionManager {
250
247
sshKeyPair : SshKeyPair ,
251
248
remoteUser : string
252
249
) : Promise < void > {
253
- const sshKey = await sshKeyPair . getPublicKey ( )
250
+ const sshPubKey = await sshKeyPair . getPublicKey ( )
254
251
255
252
const remoteAuthorizedKeysPaths = `/home/${ remoteUser } /.ssh/authorized_keys`
256
- const command = `echo "${ sshKey } " > ${ remoteAuthorizedKeysPaths } `
253
+ const command = `echo "${ sshPubKey } " > ${ remoteAuthorizedKeysPaths } `
257
254
const documentName = 'AWS-RunShellScript'
258
255
259
256
await this . ssmClient . sendCommandAndWait ( selection . instanceId , documentName , {
0 commit comments