Skip to content
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

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

Open
tylerszabo opened this issue May 25, 2021 · 6 comments

Comments

@tylerszabo
Copy link

tylerszabo commented May 25, 2021

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 tylerszabo changed the title Using CTRL+C in an SSH session with X11 forwarding and XAuthLocation set will cause ssh to terminate with error Using CTRL+C in an SSH session with X11 forwarding and XAuthLocation set will cause ssh to terminate with error May 25, 2021
@tylerszabo
Copy link
Author

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

@tankeco
Copy link

tankeco commented Aug 12, 2021

same in 8.6.0.0

@ejdaly
Copy link

ejdaly commented Sep 11, 2021

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

@Simba98
Copy link

Simba98 commented Jan 1, 2022

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

@rkitover
Copy link

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 added a commit to rkitover/windows-dev-guide that referenced this issue Mar 16, 2022
Remove XAuthLocation from ~/.ssh/config because it traps CTRL-C in ssh
sessions from the X11 Forwarding section, more info here:

PowerShell/Win32-OpenSSH#1803

Signed-off-by: Rafael Kitover <[email protected]>
@Farmbuyer
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants