Win32-OpenSSH icon indicating copy to clipboard operation
Win32-OpenSSH copied to clipboard

Using `CTRL+C` in an SSH session with X11 forwarding and `XAuthLocation` set will cause ssh to terminate with error

Open tylerszabo opened this issue 3 years ago • 6 comments

Troubleshooting steps https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubleshooting-Steps

Terminal issue? please go through wiki https://github.com/PowerShell/Win32-OpenSSH/wiki/TTY-PTY-support-in-Windows-OpenSSH

Please answer the following

"OpenSSH for Windows" version ((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion)

8.1.0.1

Server OperatingSystem ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName)

Debian 10.9 (4.19.0-16-amd64)

Client OperatingSystem

Windows 10 Pro (10.0.19043.985)

What is failing

Using CTRL+C in an SSH session with X11 forwarding and XAuthLocation set to a program will cause ssh to crash with exit status -1.

Using VcXsrv here's a matrix of the outcomes where "Fail" indicates ssh exiting with status -1 and "Pass" indicates CTRL+C was passed through the connection (in my case to my shell on the server).

Note that these examples are to show which states cause CTRL+C to kill ssh, not all cases will succeed in forwarding X11.

For access control enabled tests VcXsrv was run with vcxsrv :0 -multiwindow -clipboard -wgl -swrastwgl -auth %USERPROFILE%\.Xauthority and %USERPROFILE%\.Xauthority was configured with xauth generate . such that xauth list shows an entry. For access control disabled tests VcXsrv was run with vcxsrv.exe :0 -multiwindow -clipboard -wgl -swrastwgl -ac.

XAuthLocation Forwarding Mode Access Control X11 Forwarded CTRL-C Passed
C:\Progra~1\VcXsrv\xauth.exe -Y ✔ Enabled ✔ Yes ❌ No
C:\Progra~1\VcXsrv\xauth.exe -X ✔ Enabled ✔ Yes ❌ No
C:\Progra~2\GnuWin32\bin\true.exe -Y ✔ Enabled ❌ No ❌ No
C:\Progra~2\GnuWin32\bin\true.exe -X ✔ Enabled ❌ No ❌ No
C:\Progra~2\GnuWin32\bin\false.exe -Y ✔ Enabled ❌ No ❌ No
C:\Progra~2\GnuWin32\bin\false.exe -X ✔ Enabled ❌ No ❌ No
C:\Windows\System32\calc.exe -Y ✔ Enabled ❌ No ❌ No
C:\Windows\System32\calc.exe -X ✔ Enabled ❌ No ❌ No
NUL -Y ✔ Enabled ❌ No ✔ Yes
NUL -X ✔ Enabled ❌ No ✔ Yes
C:\Progra~1\VcXsrv\xauth.exe -Y ⚠ Disabled ✔ Yes ❌ No
C:\Progra~1\VcXsrv\xauth.exe -X ⚠ Disabled ✔ Yes ❌ No
C:\Progra~2\GnuWin32\bin\true.exe -Y ⚠ Disabled ✔ Yes ❌ No
C:\Progra~2\GnuWin32\bin\true.exe -X ⚠ Disabled ❌ No ❌ No
C:\Progra~2\GnuWin32\bin\false.exe -Y ⚠ Disabled ✔ Yes ❌ No
C:\Progra~2\GnuWin32\bin\false.exe -X ⚠ Disabled ❌ No ❌ No
C:\Windows\System32\calc.exe -Y ⚠ Disabled ✔ Yes ❌ No
C:\Windows\System32\calc.exe -X ⚠ Disabled ❌ No ❌ No
NUL -Y ⚠ Disabled ✔ Yes ✔ Yes
NUL -X ⚠ Disabled ❌ No ✔ Yes

If there is no X11 Forwarding the setting of XAuthLocation is irrelevant and CTRL+C is correctly passed.

Expected output

No exit failure when CTRL+C is passed to the program running in the SSH session, even when X11 access control is enabled and configured.

XAuthLocation Forwarding Mode Access Control X11 Forwarded CTRL-C Passed
C:\Progra~1\VcXsrv\xauth.exe -Y ✔ Enabled ✔ Yes ✔ Yes
C:\Progra~1\VcXsrv\xauth.exe -X ✔ Enabled ✔ Yes ✔ Yes
C:\Progra~1\VcXsrv\xauth.exe -Y ⚠ Disabled ✔ Yes ✔ Yes
C:\Progra~1\VcXsrv\xauth.exe -X ⚠ Disabled ✔ Yes ✔ Yes
C:\Progra~2\GnuWin32\bin\false.exe -Y ⚠ Disabled ✔ Yes ✔ Yes

Actual output

Exit with status -1

tylerszabo avatar May 25 '21 15:05 tylerszabo

This seems to be related to #1182 and possibly related to #1675. It may also be related to #1593, #1563, and #1181.

tylerszabo avatar May 25 '21 17:05 tylerszabo

same in 8.6.0.0

tankeco avatar Aug 12 '21 10:08 tankeco

CTRL+\ seems to work OK in some cases - which may be a help to people until this is resolved...

ejdaly avatar Sep 11 '21 23:09 ejdaly

Same issue. And sometimes I notice that the issue will happen in:

  1. Open a ssh.exe -X with XAuthLocation.
  2. Open the second ssh.exe without XAuthLocation.
  3. Type Ctrl-C in the second ssh.exe, it will also be killed. But due to without XAuthLocation it should work well.

Somehow I guess this is due to something outside of OpenSSH, related to windows.

((Get-Item (Get-Command ssh).Source).VersionInfo.FileVersion) 8.1.0.1

Windows version is: 19044.1415

Simba98 avatar Jan 01 '22 07:01 Simba98

I can reproduce this with the xauth.exe from the vcxsrv Chocolatey package.

When I place the following in my ~/.ssh/config:

XAuthLocation "/Program Files/VcXsrv/xauth.exe"

pressing CTRL-C in an ssh session with X11 forwarding enabled as follows:

Host myserver
    ForwardX11 yes
    ForwardX11Trusted yes

terminates the session.

(gi /Windows/System32/OpenSSH/ssh.exe).versioninfo.fileversion
# 8.6.0.1
Windows 11 build 22543 X64

rkitover avatar Mar 16 '22 19:03 rkitover

Something similar happens when port forwarding with -L is performed, and -N is given to not request a terminal on the far end. (Using 8.1.0.1 under Windows 10 Enterprise.)

  1. Launch a PowerShell window.
  2. ssh -i private-key-file.pem -L 12345:remote.host.address:67890 -N [email protected]
  3. Wait a few seconds for authentication to complete and the port forwarding to take effect.
  4. ^C should end the ssh.exe process and close the tunnel, but nothing happens. Same for Ctrl+\ from the comments above, no luck.

Only way I've found of ending the ssh process is to open task manager, find the ssh.exe task (under the PowerShell task if the task manager is set to group them), and killing it -- at which point the PowerShell window prints out all of the ^C and ^\ keystrokes that were entered.

Farmbuyer avatar Jul 07 '22 19:07 Farmbuyer