Skip to content

Invoking ssh in a command substitution in a ProxyCommand hangs #2305

Open
@phil-blain

Description

@phil-blain

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

I'm using a ProxyCommand that itself invokes SSH via command substitution in PowerShell, which can be simplified to the following configuration:

Host host
    User <user-on-host>
Host test
    User <user-on-host>
    ProxyCommand powershell.exe -noprofile -command "ssh -x -W $(ssh -x -n host echo host):%p host"

where host is a Linux host I have access to, i.e. I can do ssh host. I invoke the following command:

ssh test

This command hangs.

The same configuration works in WSL (OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022), and connects me to host. EDIT 2024-12-01 An equivalent configuration also works in WSL, which does not involve PowerShell:

Host host
    User <user-on-host>
Host test2
    User <user-on-host>
    ProxyCommand ssh -W $(ssh -x -n host echo host):%p host

Expected behavior

I get a shell on host.

Actual behavior

The command hangs. When I type ctrl-c, I get:

chan_shutdown_write: channel 0: close() failed for fd -1 [i3 o1]: Interrupted function call

Error details

PowerShell does not return an error.

Environment data

Name                           Value                                                                                                                                                                            
----                           -----                                                                                                                                                                            
PSVersion                      5.1.22621.4249                                                                                                                                                                   
PSEdition                      Desktop                                                                                                                                                                          
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                          
BuildVersion                   10.0.22621.4249                                                                                                                                                                  
CLRVersion                     4.0.30319.42000                                                                                                                                                                  
WSManStackVersion              3.0                                                                                                                                                                              
PSRemotingProtocolVersion      2.3                                                                                                                                                                              
SerializationVersion           1.1.0.1

Version

OpenSSH_for_Windows_9.8p1 Win32-OpenSSH-GitHub, LibreSSL 3.9.2

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions