-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invoking ssh
in a command substitution in a ProxyCommand
hangs
#2305
Comments
I'm trying to debug this in Visual Studio 2022 using the "Microsoft Child Process Debugging Power Tool 2022" extension. I modified my
so that all SSH instances use my debug build of
and I the server responds (I'm running the server with After that, I continue execution and nothing happens. If I then pause execution in VS, the call stack of the inner SSH is this:
and if I go to the frame highlighted with /*
* we report to POSIX app that an async write has completed as soon its
* copied to internal buffer. The app may subsequently try to close the
* fd thinking everything is written. IF the Windows handle is closed
* now, the pipe/file io write operation may terminate prematurely.
* To compensate for the discrepency
* wait here until async write has completed.
* If you see any process waiting here indefinitely - its because no one
* is draining from other end of the pipe/file. This is an unfortunate
* consequence that should otherwise have very little impact on practical
* scenarios.
*/
while (pio->write_details.pending)
if (0 != wait_for_any_event(NULL, 0, INFINITE))
return -1; which was added in PowerShell/openssh-portable@4edff78b9 (Fixed issue in POSIX layer that could truncate write streams (PowerShell/openssh-portable#235), 2017-11-06) by @manojampalam. This seems coherent with the |
Another data point, I tried this alternative approach:
and the behaviour is the same. I get no output from |
Please try building and using private binaries from this PR. ( |
Thank you for the suggestion ! I tried building from that branch, it did not change the behaviour. I also tried with different values of environment variable |
Can you try applying the same timeout from https://github.com/PowerShell/openssh-portable/pull/763/files to where this hang is occurring in https://github.com/PowerShell/openssh-portable/blob/b89ee6aa372f03fd10ae13e5af23b44be4456c79/contrib/win32/win32compat/fileio.c#L1089-L1103? |
Prerequisites
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:
where
host
is a Linux host I have access to, i.e. I can dossh 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:Expected behavior
I get a shell on
host
.Actual behavior
The command hangs. When I type
ctrl-c
, I get:Error details
PowerShell does not return an error.
Environment data
Version
OpenSSH_for_Windows_9.8p1 Win32-OpenSSH-GitHub, LibreSSL 3.9.2
Visuals
No response
The text was updated successfully, but these errors were encountered: