X forwarding for SSH connection #14542

Closed
opened 2026-01-31 04:13:12 +00:00 by claunia · 9 comments
Owner

Originally created by @Y-Grigoriy on GitHub (Jul 16, 2021).

I try to perform X forwarding for SSH connection, using Windows terminal. I want to connect to remote machine with Red Hat operation system. Following the instructions and using ssh user_name@my-server I can connect to remote machine. However, when after connection I use command export DISPLAY=localhost:0.0 and xhost +local:user_name, I get the following message: xhost: unable to open display "localhost:0.0". Also I tried to use following advice: https://github.com/microsoft/terminal/issues/2785#issuecomment-761020305, but I got the following error:

CreateProcessW failed error:2
ssh_askpass: posix_spawn: No such file or directory
Permission denied, please try again.
CreateProcessW failed error:2
ssh_askpass: posix_spawn: No such file or directory
Permission denied, please try again.
CreateProcessW failed error:2
ssh_askpass: posix_spawn: No such file or directory
user_name@my-server: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

[process exited with code 255]

UPDATED:
This problem was solved as follows:

  1. It is necessary to modify config file (C:\Users\username\ .ssh):
Host host_name
  HostName my-server 
  User user_name 
  XAuthLocation "C:/Program Files/VcXsrv/xauth.exe"
  ForwardX11 yes
  ForwardX11Trusted yes
  1. Check or/and add environment variables (This Computer -> Properties -> Advanced System Settings -> Environment Variables):
DISPLAY=localhost:0.0
HOME=C:\Users\username
TMPDIR=%USERPROFILE%\AppData\Local\Temp
PATH=C:\Program Files\VcXsrv
  1. Write command in cmd:
    xauth generate localhost:0.0 . trusted
  2. Checking the previous command:
    xauth list
  3. In settings of Windows terminal:
    "commandline": "ssh host_name",

But now I have problem with the key combination ctrl+С. It terminates ssh-connection. Could someone help me with it?

Originally created by @Y-Grigoriy on GitHub (Jul 16, 2021). I try to perform X forwarding for SSH connection, using Windows terminal. I want to connect to remote machine with Red Hat operation system. Following the [instructions](https://stackoverflow.com/questions/57363597/how-to-use-a-new-windows-terminal-app-for-ssh) and using `ssh user_name@my-server` I can connect to remote machine. However, when after connection I use command `export DISPLAY=localhost:0.0` and `xhost +local:user_name`, I get the following message: `xhost: unable to open display "localhost:0.0"`. Also I tried to use following advice: https://github.com/microsoft/terminal/issues/2785#issuecomment-761020305, but I got the following error: ``` CreateProcessW failed error:2 ssh_askpass: posix_spawn: No such file or directory Permission denied, please try again. CreateProcessW failed error:2 ssh_askpass: posix_spawn: No such file or directory Permission denied, please try again. CreateProcessW failed error:2 ssh_askpass: posix_spawn: No such file or directory user_name@my-server: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [process exited with code 255] ``` UPDATED: This problem was solved as follows: 1. It is necessary to modify **config** file (_C:\Users\username\ .ssh_): ``` Host host_name HostName my-server User user_name XAuthLocation "C:/Program Files/VcXsrv/xauth.exe" ForwardX11 yes ForwardX11Trusted yes ``` 2. Check or/and add environment variables (_This Computer -> Properties -> Advanced System Settings -> Environment Variables_): ``` DISPLAY=localhost:0.0 HOME=C:\Users\username TMPDIR=%USERPROFILE%\AppData\Local\Temp PATH=C:\Program Files\VcXsrv ``` 3. Write command in **cmd**: `xauth generate localhost:0.0 . trusted` 4. Checking the previous command: `xauth list` 5. In settings of Windows terminal: `"commandline": "ssh host_name",` But now I have problem with the key combination _**ctrl+С**_. It terminates ssh-connection. Could someone help me with it?
claunia added the Resolution-ExternalNeeds-Tag-Fix labels 2026-01-31 04:13:12 +00:00
Author
Owner

@WSLUser commented on GitHub (Jul 16, 2021):

You can disable the keybinding ctrl+c if you want but by default, Linux kills programs with that keybinding and Windows by default uses it for copying (this is why Windows Terminal made the default keybinding Ctrl+Shift+C for copying to prevent issues with it. )Are you using Win32-OpenSSH or some other binary like from Cygwin or WSL?

@WSLUser commented on GitHub (Jul 16, 2021): You can disable the keybinding `ctrl+c` if you want but by default, Linux kills programs with that keybinding and Windows by default uses it for copying (this is why Windows Terminal made the default keybinding `Ctrl+Shift+C` for copying to prevent issues with it. )Are you using Win32-OpenSSH or some other binary like from Cygwin or WSL?
Author
Owner

@Y-Grigoriy commented on GitHub (Jul 17, 2021):

Sorry, may be you not clearly understand me. Initially, I checked ssh-connection to remote station with red hat and I don't have problem with ctrl + C. After configuration of X-forwarding (as it is written after UPDATED in my first comment) I got problem with ctrl + C. And of cause I need to use this combination at least for killing program at Linux. Thus, the question: what could have changed after configuration of X-forwarding?
Also, I don't understand your question, but I am sure that I do not use Cygwin. But I have the installed WSL on my computer.

@Y-Grigoriy commented on GitHub (Jul 17, 2021): Sorry, may be you not clearly understand me. Initially, I checked ssh-connection to remote station with **red hat** and I don't have problem with **ctrl + C**. After configuration of X-forwarding (as it is written after UPDATED in my first comment) I got problem with **ctrl + C**. And of cause I need to use this combination at least for killing program at Linux. Thus, the question: what could have changed after configuration of X-forwarding? Also, I don't understand your question, but I am sure that I do not use Cygwin. But I have the installed WSL on my computer.
Author
Owner

@zadjii-msft commented on GitHub (Jul 19, 2021):

@Y-Grigoriy Which version of ssh are you using? Does this repro in the vintage console window (cmd.exe), or does it only repro in the Windows Terminal?

@zadjii-msft commented on GitHub (Jul 19, 2021): @Y-Grigoriy Which version of `ssh` are you using? Does this repro in the vintage console window (`cmd.exe`), or does it only repro in the Windows Terminal?
Author
Owner

@Y-Grigoriy commented on GitHub (Jul 22, 2021):

@zadjii-msft, I used cmd.exe, version: OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

@Y-Grigoriy commented on GitHub (Jul 22, 2021): @zadjii-msft, I used cmd.exe, version: OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
Author
Owner

@zadjii-msft commented on GitHub (Jul 22, 2021):

If this repros in just a cmd.exe window, without the Terminal involved at all, then I'm betting that this is an OpenSSH issue, not a Terminal one. https://github.com/PowerShell/Win32-OpenSSH/issues/1803 looks fairly related

@zadjii-msft commented on GitHub (Jul 22, 2021): If this repros in just a `cmd.exe` window, without the Terminal involved at all, then I'm betting that this is an OpenSSH issue, not a Terminal one. https://github.com/PowerShell/Win32-OpenSSH/issues/1803 looks fairly related
Author
Owner

@ghost commented on GitHub (Jul 26, 2021):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Jul 26, 2021): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@Y-Grigoriy commented on GitHub (Jul 27, 2021):

@zadjii-msft, Should I close this issue or can we leave it open until the question on your link to be answered?

@Y-Grigoriy commented on GitHub (Jul 27, 2021): @zadjii-msft, Should I close this issue or can we leave it open until the question on your link to be answered?
Author
Owner

@zadjii-msft commented on GitHub (Sep 18, 2021):

Lost this one in the triage queue. Yea, let's call this /dup https://github.com/PowerShell/Win32-OpenSSH/issues/1803 until proven otherwise.

@zadjii-msft commented on GitHub (Sep 18, 2021): Lost this one in the triage queue. Yea, let's call this /dup https://github.com/PowerShell/Win32-OpenSSH/issues/1803 until proven otherwise.
Author
Owner

@ghost commented on GitHub (Sep 18, 2021):

Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!

@ghost commented on GitHub (Sep 18, 2021): Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14542