Add X11 forwarding #7406

Closed
opened 2026-01-31 01:03:09 +00:00 by claunia · 14 comments
Owner

Originally created by @TomaszGrzmilas on GitHub (Apr 14, 2020).

Description of the new feature/enhancement:

I would like to be able to run the ssh -X (-Y) command on a terminal and use the functionality available in PuTTY -> X11 Forwarding.

I got installed XLaunch and when I connect using PUTTY ssh, I can run GUI applications on remote linux server.

I was thinking if that can be done by windows terminal, without necessary to use PuTTY or even XLaunch ?

Thanx !

Originally created by @TomaszGrzmilas on GitHub (Apr 14, 2020). Description of the new feature/enhancement: I would like to be able to run the ssh -X (-Y) <servername> command on a terminal and use the functionality available in PuTTY -> X11 Forwarding. I got installed XLaunch and when I connect using PUTTY ssh, I can run GUI applications on remote linux server. I was thinking if that can be done by windows terminal, without necessary to use PuTTY or even XLaunch ? Thanx !
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 01:03:09 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Apr 14, 2020):

If you can run ssh -X outside of Terminal you can certainly run it inside terminal. This sounds like a request for the Win32-OpenSSH team.

@DHowett-MSFT commented on GitHub (Apr 14, 2020): If you can run `ssh -X` outside of Terminal you can certainly run it inside terminal. This sounds like a request for the Win32-OpenSSH team.
Author
Owner

@hensz commented on GitHub (Jul 15, 2021):

Hi there!
While it's technically possible to use X11 forwarding with Windows Terminal I have one case where it doesn't work.
When I open a WSL terminal and manually run ssh -X myhost I get a connection and can also open X11 programs. But when I use a custom profile with Command line "wsl.exe ssh -X user@myhost" I get a connection, too, but I cannot open X11 programs. Instead I get the usual error message:
xterm: Xt error: Can't open display:
xterm: DISPLAY is not set

So obviously there's a difference wrt. X11 forwarding between the "regular" WSL terminal (wsl.exe -d Ubuntu) and my custom profile. Is this a configuration error on my side, or is this a bug in Windows Terminal?

btw, I'm using the latest Preview version 1.10

@hensz commented on GitHub (Jul 15, 2021): Hi there! While it's technically possible to use X11 forwarding with Windows Terminal I have one case where it doesn't work. When I open a WSL terminal and manually run ssh -X myhost I get a connection and can also open X11 programs. But when I use a custom profile with Command line "wsl.exe ssh -X user@myhost" I get a connection, too, but I cannot open X11 programs. Instead I get the usual error message: xterm: Xt error: Can't open display: xterm: DISPLAY is not set So obviously there's a difference wrt. X11 forwarding between the "regular" WSL terminal (wsl.exe -d Ubuntu) and my custom profile. Is this a configuration error on my side, or is this a bug in Windows Terminal? btw, I'm using the latest Preview version 1.10
Author
Owner

@DHowett commented on GitHub (Jul 15, 2021):

It's likely that running wsl ssh skips parts of your profile initialization, or does not propagate the DISPLAY environment variable.

@DHowett commented on GitHub (Jul 15, 2021): It's likely that running `wsl ssh` skips parts of your profile initialization, or does not propagate the `DISPLAY` environment variable.
Author
Owner

@DHowett commented on GitHub (Jul 15, 2021):

(This is by design)

@DHowett commented on GitHub (Jul 15, 2021): (This is by design)
Author
Owner

@hensz commented on GitHub (Jul 20, 2021):

Any idea how to do this differently, where to look for further information or whom to ask? Searching for wsl ssh x-forwarding didn't help much :-(

@hensz commented on GitHub (Jul 20, 2021): Any idea how to do this differently, where to look for further information or whom to ask? Searching for wsl ssh x-forwarding didn't help much :-(
Author
Owner

@hensz commented on GitHub (Aug 11, 2021):

Hi @DHowett,
this issue is closed and my question is only partly related to the original question, so I wanted to post it somewhere else - but I don't have a clue where would be the best place to do so. Can you give me a hint? Is the behavior I reported "caused" by Windows Terminal, wsl or OpenSSH? And what is the correct reporting channel for the respective component?
Thanks in advance,
Torsten

@hensz commented on GitHub (Aug 11, 2021): Hi @DHowett, this issue is closed and my question is only partly related to the original question, so I wanted to post it somewhere else - but I don't have a clue where would be the best place to do so. Can you give me a hint? Is the behavior I reported "caused" by Windows Terminal, wsl or OpenSSH? And what is the correct reporting channel for the respective component? Thanks in advance, Torsten
Author
Owner

@DHowett commented on GitHub (Aug 27, 2021):

So! This one is a little weird. Every component here is working as it should; it's just not been told to do better. Here's what's up:

It all depends on where DISPLAY is being set. If it's being set in .bashrc or .bash_profile, you have to make sure you run ssh from bash! Without that step, those files are going to be ignored.

There's a couple things you can do to fix that. You can run ssh through bash, and tell it is a login shell (so that it sources more of its config files). wsl bash -l -c "ssh -X blah" might do the trick. You can also move DISPLAY to your Windows environment, if you're using a Windows X11 server, and then set WSLENV to include DISPLAY (so that it gets copied into WSL).

@DHowett commented on GitHub (Aug 27, 2021): So! This one is a little weird. Every component here is working as it should; it's just not been told to do better. Here's what's up: It all depends on where `DISPLAY` is being set. If it's being set in `.bashrc` or `.bash_profile`, you have to _make sure you run ssh from `bash`!_ Without that step, those files are going to be ignored. There's a couple things you can do to fix that. You can run ssh through bash, and tell it is a login shell (so that it sources more of its config files). `wsl bash -l -c "ssh -X blah"` might do the trick. You can also move DISPLAY to your Windows environment, if you're using a Windows X11 server, and then set `WSLENV` to include `DISPLAY` (so that it gets copied into WSL).
Author
Owner

@ciaochiaociao commented on GitHub (Sep 1, 2021):

@TomaszGrzmilas @hensz I also ran into this issue. Like the other said, it should not be Windows Terminal's issue. But I understand why you post here, since using PuTTY with Port Forwarding enabled simply works while Windows Terminal does not. I think PuTTY does many things under the hood in fact. To use other terminals than PuTTY, you can follow the note I wrote below.

Before you read this,
X11 server means your local workstation
X11 client means the remote you are sshing into

Option 1: Simply use PuTTY with Port Forwarding enabled

Option 2: Use ANY terminal with following steps

  1. export DISPLAY environment variable in X11 Client's (remote) shell runcom file: *rc

    # in <x11_client(remote)>:~/.bashrc or ~/.zshrc ...
    export DISPLAY=<x11_server(local)>:<display_num>.<win_num>
    # e.g.
    export DISPLAY=my.local.ip:0.0
    # or just
    export DISPLAY=my.local.ip:0
    
  2. allow ports 6000-6063 in Firewall setting

    ref: https://forums.anandtech.com/threads/what-port-does-x11-traffic-use.618859/

  3. Start X11 Server (on your workstation) with access control disabled, e.g., start VcXsrv / Xming on your windows with option: Disable Access Control (Don't forget this. Otherwise, it will show authentification error afterwards.)

All three steps need to be done, otherwise, it won't work.

  1. ssh -X <remote> from your workstation

FYI

@ciaochiaociao commented on GitHub (Sep 1, 2021): @TomaszGrzmilas @hensz I also ran into this issue. Like the other said, it should not be Windows Terminal's issue. But I understand why you post here, since using PuTTY with *Port Forwarding* enabled simply works while Windows Terminal does not. I think PuTTY does many things under the hood in fact. To use other terminals than PuTTY, you can follow the note I wrote below. Before you read this, *X11 server* means your local workstation *X11 client* means the remote you are sshing into ## Option 1: Simply use PuTTY with *Port Forwarding* enabled ## Option 2: Use ANY terminal with following steps 1. export `DISPLAY` environment variable in X11 Client's (remote) shell runcom file: `*rc` ```bash # in <x11_client(remote)>:~/.bashrc or ~/.zshrc ... export DISPLAY=<x11_server(local)>:<display_num>.<win_num> # e.g. export DISPLAY=my.local.ip:0.0 # or just export DISPLAY=my.local.ip:0 ``` 2. allow ports 6000-6063 in Firewall setting ref: https://forums.anandtech.com/threads/what-port-does-x11-traffic-use.618859/ 3. Start X11 Server (on your workstation) with access control disabled, e.g., start VcXsrv / Xming on your windows with option: *Disable Access Control* (Don't forget this. Otherwise, it will show *authentification error* afterwards.) All three steps need to be done, otherwise, it won't work. 4. `ssh -X <remote>` from your workstation FYI
Author
Owner

@zxleong commented on GitHub (Oct 19, 2021):

  1. export DISPLAY environment variable in X11 Client's (remote) shell runcom file: *rc
    # in ~/.bashrc or ~/.zshrc ...
    export DISPLAY=<x11_server_name_or_ip>:<display_num>.<win_num>
    # e.g.
    export DISPLAY=myhome.com:0.0
    # or just
    export DISPLAY=myhome.com:0
    

How do I find my x11 server name and display num?

@zxleong commented on GitHub (Oct 19, 2021): > 1. export `DISPLAY` environment variable in X11 Client's (remote) shell runcom file: `*rc` > ```shell > # in ~/.bashrc or ~/.zshrc ... > export DISPLAY=<x11_server_name_or_ip>:<display_num>.<win_num> > # e.g. > export DISPLAY=myhome.com:0.0 > # or just > export DISPLAY=myhome.com:0 > ``` How do I find my x11 server name and display num?
Author
Owner

@ciaochiaociao commented on GitHub (Oct 20, 2021):

@zxleong
X11 server: your workstation
X11 client: the remote machine you are ssh-ing to

So you can just 'ifconfig' on your local machine to find the ip.

For display name, you cab try 0 first since it is the default I guess.

  1. export DISPLAY environment variable in X11 Client's (remote) shell runcom file: *rc

in ~/.bashrc or ~/.zshrc ...

export DISPLAY=<x11_server_name_or_ip>:<display_num>.<win_num>

e.g.

export DISPLAY=myhome.com:0.0

or just

export DISPLAY=myhome.com:0

How do I find my x11 server name and display num?

@ciaochiaociao commented on GitHub (Oct 20, 2021): @zxleong X11 server: your workstation X11 client: the remote machine you are ssh-ing to So you can just 'ifconfig' on your local machine to find the ip. For display name, you cab try 0 first since it is the default I guess. > > 1. export `DISPLAY` environment variable in X11 Client's (remote) shell runcom file: `*rc` > > > ```shell > > > # in ~/.bashrc or ~/.zshrc ... > > > export DISPLAY=<x11_server_name_or_ip>:<display_num>.<win_num> > > > # e.g. > > > export DISPLAY=myhome.com:0.0 > > > # or just > > > export DISPLAY=myhome.com:0 > > > ``` > > > > > > How do I find my x11 server name and display num? > >
Author
Owner

@sisrfeng commented on GitHub (Jan 10, 2022):

step 1. export DISPLAY=localhost:0 in .zshrc.
PS: Explicitly using export DISPLAY=10.14.37.76:0 fails. (The ip is found by ipconfig and I change it a bit here, for concern of privacy )

step 2. start xming

But this method fails in alacritty, anyone knows why?

@sisrfeng commented on GitHub (Jan 10, 2022): step 1. `export DISPLAY=localhost:0` in .zshrc. PS: Explicitly using `export DISPLAY=10.14.37.76:0` fails. (The ip is found by ipconfig and I change it a bit here, for concern of privacy ) step 2. start **xming** But this method fails in alacritty, anyone knows why?
Author
Owner

@sisrfeng commented on GitHub (Feb 15, 2022):

update:
X11 forwarding success only if I keep mobaxterm ssh-ing to the same remote machine with the same localhost:11.0
(Using mobaxterm, DISPLAY will be set by mobaxterm, not forced to localhost:11.0 by zsh' s config )
This implies that it is the X-server integrated in mobaxterm, instead of Xming, that makes x11 forward success in the situation of my reply above.
but I want to uninstall mobaxterm!

How to make Xming/VcXxvr works for windows terminal ?

my zshrc
image

Same code as above, but with my notes:
image

.zshlogin:
(excuted after .zshrc)

image

Allowed by firewall
image

@sisrfeng commented on GitHub (Feb 15, 2022): update: X11 forwarding success only if I keep mobaxterm ssh-ing to the same remote machine with the same `localhost:11.0` (Using mobaxterm, DISPLAY will be set by mobaxterm, not forced to `localhost:11.0` by zsh' s config ) This implies that it is the X-server integrated in mobaxterm, instead of Xming, that makes x11 forward success in the situation of my reply above. but I want to uninstall mobaxterm! How to make Xming/VcXxvr works for windows terminal ? my zshrc ![image](https://user-images.githubusercontent.com/53520949/154062025-e3ed2ff0-15bd-4a3a-8caf-3548666ccfcf.png) Same code as above, but with my notes: ![image](https://user-images.githubusercontent.com/53520949/154062122-b880b256-24e3-45f9-8791-a8a6675a780a.png) .zshlogin: (excuted after .zshrc) ![image](https://user-images.githubusercontent.com/53520949/154062714-8013a0c3-d033-4531-a8f9-f1cf0b439d99.png) Allowed by firewall ![image](https://user-images.githubusercontent.com/53520949/155316094-f534b42f-82ee-461f-90b0-9dc644ade503.png)
Author
Owner

@Zhaoyilunnn commented on GitHub (Oct 14, 2024):

update: X11 forwarding success only if I keep mobaxterm ssh-ing to the same remote machine with the same localhost:11.0 (Using mobaxterm, DISPLAY will be set by mobaxterm, not forced to localhost:11.0 by zsh' s config ) This implies that it is the X-server integrated in mobaxterm, instead of Xming, that makes x11 forward success in the situation of my reply above. but I want to uninstall mobaxterm!

How to make Xming/VcXxvr works for windows terminal ?

my zshrc image

Same code as above, but with my notes: image

.zshlogin: (excuted after .zshrc)

image

Allowed by firewall image

Exactly the same problem with you

@Zhaoyilunnn commented on GitHub (Oct 14, 2024): > update: X11 forwarding success only if I keep mobaxterm ssh-ing to the same remote machine with the same `localhost:11.0` (Using mobaxterm, DISPLAY will be set by mobaxterm, not forced to `localhost:11.0` by zsh' s config ) This implies that it is the X-server integrated in mobaxterm, instead of Xming, that makes x11 forward success in the situation of my reply above. but I want to uninstall mobaxterm! > > How to make Xming/VcXxvr works for windows terminal ? > > my zshrc ![image](https://user-images.githubusercontent.com/53520949/154062025-e3ed2ff0-15bd-4a3a-8caf-3548666ccfcf.png) > > Same code as above, but with my notes: ![image](https://user-images.githubusercontent.com/53520949/154062122-b880b256-24e3-45f9-8791-a8a6675a780a.png) > > .zshlogin: (excuted after .zshrc) > > ![image](https://user-images.githubusercontent.com/53520949/154062714-8013a0c3-d033-4531-a8f9-f1cf0b439d99.png) > > Allowed by firewall ![image](https://user-images.githubusercontent.com/53520949/155316094-f534b42f-82ee-461f-90b0-9dc644ade503.png) Exactly the same problem with you
Author
Owner

@Zhaoyilunnn commented on GitHub (Feb 8, 2025):

How to make Xming/VcXxvr works for windows terminal ?

https://superuser.com/questions/1610181/connecting-to-x11-using-windows-10-openssh-and-vcxsrv

This works for me.

@Zhaoyilunnn commented on GitHub (Feb 8, 2025): > How to make Xming/VcXxvr works for windows terminal ? https://superuser.com/questions/1610181/connecting-to-x11-using-windows-10-openssh-and-vcxsrv This works for me.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7406