-
Notifications
You must be signed in to change notification settings - Fork 486
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
sshpass does not work with Windows Terminal app and msys2 console #3579
Comments
Where did you get / how have you built the |
It's an msys2 package.
|
same problem |
If sshpass works with msys2's default terminal program (mintty), why is this not an issue of Windows Terminal? |
@brendan-simon-indt commented 3 weeks ago:
What do you get if you run |
If I run from an
Doing the same things from
It could be a |
I would try running |
Encountered the same problem, add a little verbose information:
|
I found sshpass only work with mintty and conemu, and if use conemu, must start with conemu-msys2-64.exe, I can use conemu-msys2-64.exe with bash.exe in windows terminal, sshpass will work, but it can't enable xterm-256color,maybe have some bugs, if direct use msys2_shell.cmd or bash.exe, sshpass can't work, not just windows terminal, i have already tried windows terminal, conemu, cmder, tabby, hyper.js, all can't work |
@brendan-simon-indt commented on Feb 18:
I would like to reproduce this. Just installed Windows Terminal version 1.16.10261.0: But MSYS2 terminal isn't here: Did you configure it by hand or was it added there automatically on your machine? |
@sskras: Instructions for setting up the Windows Terminal for the MSYS2 environments are here: https://www.msys2.org/docs/terminals/ |
@sskras I can't remember now. This is what is in my settings. I guess I may have set it up myself. |
Thanks, it comes probably from here: https://www.msys2.org/docs/terminals/#windows-terminal // This makes UCRT64 the default shell
"defaultProfile": "{17da3cac-b318-431e-8a3e-7fcdefe6d114}",
"profiles": {
"list":
[
// ...
{
"guid": "{17da3cac-b318-431e-8a3e-7fcdefe6d114}",
"name": "UCRT64 / MSYS2",
"commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -ucrt64",
"startingDirectory": "C:/msys64/home/%USERNAME%",
"icon": "C:/msys64/ucrt64.ico",
"font":
{
"face": "Lucida Console",
"size": 9
}
},
{
"guid": "{71160544-14d8-4194-af25-d05feeac7233}",
"name": "MSYS / MSYS2",
"commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -msys",
"startingDirectory": "C:/msys64/home/%USERNAME%",
"icon": "C:/msys64/msys2.ico",
"font":
{
"face": "Lucida Console",
"size": 9
}
},
// ...
]
} |
I can confirm that the issue is present in MSYS2. The tested WT profile:
This can also be reproduced without Windows Terminal by simply running MSYS2 from
Without the This also affects Cygwin. The tested WT profile:
Tested command lines:
|
I tested printing version of the SSH client while running under
If I run this from MinTTY, version is shown:
Now if run this from console I/O based environment (
Not sure if it counts as a reduced test case. But clearly all this is related to the initial terminal I/O setup. |
I tried stracing the
[ptymf] sshpass CPID1 SetThreadName: SetThreadDescription() failed. 00000000 10000000
- [main] sshpass CPID1 fhandler_pty_master::setup: this 0x800009A90, pty0 opened - from_pty <0x1A4,0x1C0>, to_pty 0x1A0
+ [main] sshpass CPID1 fhandler_pty_master::setup: this 0x800009A90, pty1 opened - from_pty <0x208,0x210>, to_pty 0x204
[main] sshpass CPID1 fhandler_base::open_with_arch: line 451: /dev/ptmx<0x800009E00> usecount + 1 = 1
[main] sshpass CPID1 fhandler_base::set_flags: flags 0x18002, supplied_bin 0x0
[main] sshpass CPID1 fhandler_base::set_flags: O_TEXT/O_BINARY set in flags 0x10000
[main] sshpass CPID1 fhandler_base::set_flags: filemode set to binary
- [main] sshpass CPID1 fhandler_pty_master::open_setup: /dev/ptmx opened pty master for pty0, usecount 1
+ [main] sshpass CPID1 fhandler_pty_master::open_setup: /dev/ptmx opened pty master for pty1, usecount 1
[main] sshpass CPID1 open: 3 = open(/dev/ptmx, 0x8002)
[main] sshpass CPID1 fcntl: fcntl(3, 4, ...)
[main] sshpass CPID1 fhandler_base::set_flags: flags 0x1C002, supplied_bin 0x0
[main] sshpass CPID1 fhandler_base::set_flags: O_TEXT/O_BINARY set in flags 0x10000
[main] sshpass CPID1 fhandler_base::set_flags: filemode set to binary
[main] sshpass CPID1 fcntl: 0 = fcntl(3, 4, 0x4000)
[main] sshpass CPID1 open: open(/dev/tty, 0x0)
+--- Process WPID1 (pid: CPID1) loaded C:\Windows\System32\user32.dll at 00007ff887650000
+--- Process WPID1 (pid: CPID1) loaded C:\Windows\System32\win32u.dll at 00007ff886c60000
+--- Process WPID1 (pid: CPID1) loaded C:\Windows\System32\gdi32.dll at 00007ff8894c0000
+--- Process WPID1 (pid: CPID1) loaded C:\Windows\System32\gdi32full.dll at 00007ff886d90000
+--- Process WPID1 (pid: CPID1) loaded C:\Windows\System32\msvcp_win.dll at 00007ff887360000
+--- Process WPID1 (pid: CPID1) loaded C:\Windows\System32\imm32.dll at 00007ff888820000
[main] sshpass CPID1 build_argv: cmd = 'sshpass -e ssh myhostname id', winshell = 1, glob = 1
[main] sshpass CPID1 build_argv: argv[0] = 'sshpass'
[main] sshpass CPID1 build_argv: argv[1] = '-e'
[main] sshpass CPID1 build_argv: argv[2] = 'ssh'
[main] sshpass CPID1 build_argv: argv[3] = 'myhostname'
[main] sshpass CPID1 build_argv: argv[4] = 'id'
[main] sshpass CPID1 build_argv: argc 5
- [main] sshpass CPID1 open_shared: name dd50a72ab4668b33-cons0x150AD8.0, shared 0x1A3000000 (wanted 0x1A3000000), h 0x1AC, m 3, created 0
- [main] sshpass CPID1 open_shared: name cygpid.CPID2, shared 0x1A4000000 (wanted 0x1A4000000), h 0x184, m 6, created 0
+ [main] sshpass CPID1 open_shared: name dd50a72ab4668b33-cons0x5C072C.0, shared 0x1A3000000 (wanted 0x1A3000000), h 0x1C8, m 3, created 1
+--- Process WPID1 (pid: CPID1) thread WTID4 created
+ [consm] sshpass CPID1 cygthread::stub: thread 'consm', id 0x3EC8, stack_ptr 0x29DCCB0
+ [consm] sshpass CPID1 SetThreadName: SetThreadDescription() failed. 00000000 10000000
[main] sshpass CPID1 fhandler_base::open_with_arch: line 451: /dev/cons0<0x800008D60> usecount + 1 = 1
[main] sshpass CPID1 fhandler_base::set_flags: flags 0x10002, supplied_bin 0x0
[main] sshpass CPID1 fhandler_base::set_flags: O_TEXT/O_BINARY set in flags 0x10000
[main] sshpass CPID1 fhandler_base::set_flags: filemode set to binary
[main] sshpass CPID1 _pinfo::set_ctty: old no ctty, ctty device number 0xFFFFFFFF, tc.ntty device number 0x30000 flags & O_NOCTTY 0x0
[main] sshpass CPID1 _pinfo::set_ctty: cygheap->ctty 0x0, archetype 0x800008D60
[main] sshpass CPID1 _pinfo::set_ctty: ctty was NULL
[main] sshpass CPID1 _pinfo::set_ctty: line 548: /dev/cons0<0x800008D60> usecount + 1 = 2
[main] sshpass CPID1 _pinfo::set_ctty: /dev/cons0 ctty, usecount 2
- [main] sshpass CPID1 _pinfo::set_ctty: attaching ctty /dev/cons0 sid CPID1, pid CPID1, pgid CPID1, tty->pgid CPID7, tty->sid CPID2
+ [main] sshpass CPID1 _pinfo::set_ctty: attaching ctty /dev/cons0 sid CPID1, pid CPID1, pgid CPID1, tty->pgid CPID1, tty->sid 0
[main] sshpass CPID1 _pinfo::set_ctty: cygheap->ctty now 0x800008D60, archetype 0x800008D60 I lack the exact understanding of inner Cygwin/MSYS2 mechanisms. We need more qualified expertise to narrow the bug down. After that it might get clearer if the issue really belongs to this repo (instead of msys2/msys2-runtime) or IOW, |
Also ping @Shachar, the developer of |
For Cygwin tty/console, you can't get more qualified expertise than @tyan0. It would probably be interesting to know if this happens as described under upstream Cygwin (I expect it does), and then whether it still happens under a Cygwin 3.5 snapshot. |
There's a chance the problem isn't with MSYS or sshpass (exactly), but with the version of ssh you're using. See https://sourceforge.net/p/sshpass/bugs/27/ on the upstream sshpass package. In a nutshell, some ssh versions close their stdout and stderr, and redirect it to their own terminal. Since sshpass doesn't copy between the TTY and stdout/err, the output never goes anywhere. |
@jeremyd2019 commented 3 hours ago:
Thanks for inviting a skilled person! :)
I commented 2 days ago that Cygwin fails in a similar manner. I think it's quite up to date:
I would give it a shot on my machine should I know how to bootstrap this: |
I have confirmed that this issue also occurs in cygwin 3.4.6, but not in the latest cygwin 3.5.0 (Test). This issue seems to be due to a long-standing limitation of console implementation that the console is inaccessible from other terminals that are associated with other tty. Only console (command prompt, windows terminal etc.) has this limitation but pty (mintty, xterm etc.) does not. A several months ago, I applied a relatively agressive patch (mirror/newlib-cygwin@3721a75) to the cygwin master branch so that GNU screen and tmux get working in console. It seems that this patch solves this issue as well. Therefore, you can expect that sshpass will work also on console with upcoming v3.5.x. Cygwin v3.5.x will be released within 2023. |
Awesome. Can't come soon enough. |
ping @lazka: should this be moved into Also I would change the title: -sshpass does not work with Windows Terminal app and msys2 console
+combination of `sshpass` and `ssh` from MSYS2 renders no output in Windows console |
It's ok here, I guess. The issue with sshpass which belongs to this MSYS2-packages repository. |
@Biswa96: no, the issue is with msys2-3.4.6/winsup/cygwin:
Specifically with the winsup/cygwin/fhandler/console.cc file, eg. the Because of this applications like tmux also fail: I expect GNU Screen to fail too (but MSYS2 doesn't build it). |
@tyan0 @sskras |
https://cygwin.com/pipermail/cygwin-announce/2024-January/011483.html |
Okay, I'll patiently wait for a while. |
Description / Steps to reproduce the issue
sshpass works with ssh if I run from a stock standard msys2 terminal (or mingw64, clang, ucrt, ...).
sshpass works with Windows Terminal app, if using sshpass with windows ssh, but not with msys2 ssh.
sshpass does not work with Windows Terminal app with a msys2, mingw64, ... terminal in a tab. I get absolutely no output. I don't know if this is an issue with sshpass or Windows Terminal app.
NOTE: the ssh command after the sspass does work if given by itself (I have ssh rsa keys setup)
Install Windows Terminal app from the Windows Store
https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-au&gl=au&rtc=1
Open up an msys terminal from the drop down menu.
Issue sspass command. e.g. sshpass -puserpassword user@host ls
Expected behavior
Output to be displayed in terminal.
Actual behavior
absolutely no output
Verification
Windows Version
MSYS_NT-10.0-19044
Are you willing to submit a PR?
unlikely
The text was updated successfully, but these errors were encountered: