aws-toolkit-vscode: EC2 Remote from Windows : ec2_connect.ps1 missing
Problem
When trying the new experimental feature to “connect to EC2 instance in a new Remote window” from Windows, the script ec2_connect.ps1 is missing.
Logs :
2024-12-16 13:36:48.386 [error] aws.ec2.openRemoteConnection: Error: Failed to update connect script [ConnectScriptUpdateFailed]
-> EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open 'c:\Users\[redacted]\.vscode\extensions\amazonwebservices.aws-toolkit-vscode-3.39.0\resources\ec2_connect.ps1' [FileNotFound]
Steps to reproduce the issue
- Start VSCode on Windows, with AWS Toolkit 3.39
- Enable experimental feature “ec2RemoteConnect”
- Browse to an EC2 in AWS Toolkit explorer
- Click the button “connect to EC2 instance in a new Remote window”
- The error is shown
Expected behavior
I should be able to open a new VSCode window, connected to this remote EC2 through SSM.
System details (run AWS: About and/or Amazon Q: About)
- OS: Windows 11
- Visual Studio Code version: 1.96.0
- AWS Toolkit version: 3.39.0
- Amazon Q version: NA
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 5
- Comments: 22 (5 by maintainers)
Connecting from Windows is not yet implemented. We plan to follow up on this.
Just as a recap for others looking at this to save yourself the two hours it took me:
C:\Users\<USERNAME>\.cursor\extensions\amazonwebservices.aws-toolkit-vscode-3.57.0\dist\src\extensionNode.jsand find and replacepowershell.exewithpwsh(note that file path is for cursor, but just use.vscodefor vscodeamazonwebservices.aws-toolkit-vscode-3.57.0\resourcesfolder asec2_connect.ps1.The PR has been merged, so hopefully a release soon will contain the fix but for now this is how you can do.
We’re certainly open to changing https://github.com/aws/aws-toolkit-vscode/blob/1d79df7ea7e9d44ad86e0fdb20d7f1fa4d67eca1/packages/core/src/shared/extensions/ssh.ts#L72 if that’s the code you are referring to. Or could update that function to try both powershell.exe and
pwsh, and use the first one that succeeds.@nathanlisabio Thanks for the info, I managed to track it down and change the file locally and also have it working! I had to edit the contents of .vscode\extensions\amazonwebservices.aws-toolkit-vscode-3.50.0\dist\src\extensionNode.js to replace three occurrences of
powershell.exewithpwshupdates:
got connect via vscode to work (with caveats)
2025-03-18 01:29:48.370 [error] aws.ec2.openRemoteConnection: Error: Unrecognized OS name Amazon Linux AMI on instance i-0890259255f2712c1 [UnknownEc2OS])2025-03-18 01:42:59.750 [warning] ec2: failed to clean keys: 'Error: Failed in sending command to target i-0e190c5ec1e3c650c\n' + '\t -> Error: {"state":"FAILURE","reason":{"$metadata":{"httpStatusCode":200,"requestId":"20d8db59-60ef-4154-8e28-40e3b8e1bec5","attempts":1,"totalRetryDelay":0},"CloudWatchOutputConfig":{"CloudWatchLogGroupName":"","CloudWatchOutputEnabled":false},"CommandId":"7f86a4b0-b395-40d7-b0d7-340096b4fe65","Comment":"","DocumentName":"AWS-RunShellScript","DocumentVersion":"$DEFAULT","ExecutionElapsedTime":"PT0.004S","ExecutionEndDateTime":"2025-03-18T05:42:54.732Z","ExecutionStartDateTime":"2025-03-18T05:42:54.732Z","InstanceId":"i-0e190c5ec1e3c650c","PluginName":"aws:runShellScript","ResponseCode":1,"StandardErrorContent":"","StandardErrorUrl":"","StandardOutputContent":"","StandardOutputUrl":"","Status":"Failed","StatusDetails":"Failed"},"observedResponses":{"400: UnknownError":1,"200: OK":1}}'2025-03-18 01:43:05.175 [error] aws.ec2.openRemoteConnection: Error: Failed in sending command to target i-0e190c5ec1e3c650c -> Error: {"state":"FAILURE","reason":{"$metadata":{"httpStatusCode":200,"requestId":"564bfa05-8b95-4785-a444-781de4f48a3f","attempts":1,"totalRetryDelay":0},"CloudWatchOutputConfig":{"CloudWatchLogGroupName":"","CloudWatchOutputEnabled":false},"CommandId":"85f11865-f926-4e34-9d4a-63fcdbeaaab5","Comment":"","DocumentName":"AWS-RunShellScript","DocumentVersion":"$DEFAULT","ExecutionElapsedTime":"PT0S","ExecutionEndDateTime":"2025-03-18T05:43:00.136Z","ExecutionStartDateTime":"2025-03-18T05:43:00.136Z","InstanceId":"i-0e190c5ec1e3c650c","PluginName":"aws:runShellScript","ResponseCode":1,"StandardErrorContent":"","StandardErrorUrl":"","StandardOutputContent":"","StandardOutputUrl":"","Status":"Failed","StatusDetails":"Failed"},"observedResponses":{"400: UnknownError":1,"200: OK":1}}2025-03-18 01:43:09.860 [info] telemetry: sent batch (size=9)powershell.exe(the default come-with pwsh) does not pass thetestSshConnectionfunction, causing the unknown port issue mentioned earlier. By changing it to pwsh (v7.5.0), it just worked… (sshConfig.ts). I’m unsure which direction to go to debug why v5.1 encounters this issueduring testing, encountered other issues that are not related to this issue
https://github.com/aws/aws-toolkit-vscode/issues/6802
Before connecting, AWS Toolkit tries a test command to ensure that things will actually work: https://github.com/aws/aws-toolkit-vscode/blob/1d79df7ea7e9d44ad86e0fdb20d7f1fa4d67eca1/packages/core/src/shared/extensions/ssh.ts#L150
That is failing from a
Connection closed by UNKNOWN port 65535error, which seems like a network or permissions issue.some updates:
2025-03-06 21:58:23.729 [error] aws.ec2.openRemoteConnection: Error: Unable to connect to target instance {the instance id redacted} on region us-east-1. Testing SSM connection to instance failed: Connection closed by UNKNOWN port 65535 [EC2SSMTestConnect] 2025-03-06 22:00:56.941 [info] telemetry: sent batch (size=19)here is the ai generated version i am working on testing