Skip to content

BUG in connect VS Code in EC2 #8787

@darlangui

Description

@darlangui

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\<user>\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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugWe can reproduce the issue and confirmed it is a bug.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions