aws / aws/aws-toolkit-vscode

BUG in connect VS Code in EC2

Open
#8,787 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2k
Forks
807
Avg merge
10h 12m
Merged PRs (30d)
7

Description

## Problem

When attempting to use **"Connect VS Code to EC2"** via AWS Toolkit (v4.4.0) on Windows, the connection fails during SSH configuration generation.

The error occurs during the SSH config validation step and prevents establishing the remote connection.

Relevant sanitized error log:

[error] ec2: failed to add ssh config section:
Pseudo-terminal will not be allocated because stdin is not a terminal.
vdollar_percent_expand: unknown key %r
percent_dollar_expand: failed

Final error returned by the extension:

[SshCheckFailed]

Additional context:

* AWS authentication (SSO) succeeds correctly
* SSH binary is detected correctly
* Key pair generation succeeds
* Failure happens specifically when processing SSH config (`ssh -G`)

Also observed:

* Warning about missing default region (falls back to us-east-1)
* `session-manager-plugin` not being detected initially

***

## Steps to reproduce the issue

1. Open VS Code with AWS Toolkit installed
2. Authenticate using AWS SSO
3. Navigate to EC2 instances
4. Click **"Connect to EC2 using VS Code"**
5. Select the target instance
6. Wait for the connection process to initialize

***

## Expected behavior

VS Code should:

* Generate a valid SSH config
* Establish a remote connection to the EC2 instance
* Open a remote workspace successfully

***

## Sytem details (run `AWS: About`) and/or `Amazon Q: About`

* **OS:** Windows 11 Enterprise (Version 25H2, Build 10.0.26200)
* **Visual Studio Code version:** 1.120.0
* Electron: 39.8.8
* Node: 22.22.1
* V8: 14.2.231.22-electron.0
* **AWS Toolkit Version:** 4.4.0
* **Amazon Q version:** (not explicitly shown in logs)

***

## Additional context

### 1. SSH environment

The error strongly suggests an issue in SSH config parsing:

vdollar_percent_expand: unknown key %r

This may indicate incompatibility between:

* The generated SSH config from AWS Toolkit
* The SSH client being used on Windows (`Git Bash ssh.exe`)

Detected SSH binary:

C:\Users\\AppData\Local\Programs\Git\usr\bin\ssh.exe

***

### 2. Session Manager plugin

Logs show:

Command: session-manager-plugin.exe --version (not started)

This may indicate:

* Plugin not installed
* Plugin not in PATH
* Or Toolkit failing to locate it properly

***

### 3. Cross-platform test (Linux / WSL)

The same issue was reproduced in a **Kali Linux environment (Debian-based)** running via WSL.

Command used:

wsl --install kali-linux

Observed behavior:

* The connection flow fails with an error referencing Windows-specific path:

C:\WINDOWS\system32\wsl.exe

This suggests:

* AWS Toolkit may be incorrectly assuming a Windows host context even when running inside WSL
* Or misdetecting the execution environment

***

### 4. Goal of this issue

The goal is to understand:

* Why the SSH config generation fails (`%r` expansion error)
* Whether this is related to:
* SSH client compatibility (OpenSSH vs Git SSH)
* AWS Toolkit config generation bug
* Missing dependencies (session-manager-plugin)
* Environment detection issues (Windows vs WSL)
* What is the correct setup required to make **EC2 remote connection via VS Code** work reliably on Windows.

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named. Start by reproducing the SSH config validation with `ssh -G` using the detected Git Bash `ssh.exe`, then compare the Windows and WSL behavior and check the session-manager-plugin detection; done means identifying the failing dependency or environment assumption and establishing a reliable EC2 connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, vscode
Domain
cloud, devtools, networking, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.