大网数据广告活动
服务器运维问答

X11 Forwarding: GUI appears in the remote server instead of client

· 52CE 我爱测

I have two machines, PC1 and PC2 . in PC1 I have Msys2 and Xming installed on Windows 7 while in the second machine PC2 I have Windows 10 with Ubuntu 18.04 on WSL (Windows Subsystem for Linux), Xming is also installed. I configur…

问题原文

原帖链接 · s.ouchene · CC BY-SA 4.0

I have two machines, PC1 and PC2. in PC1 I have Msys2 and Xming installed on Windows 7 while in the second machine PC2 I have Windows 10 with Ubuntu 18.04 on WSL (Windows Subsystem for Linux), Xming is also installed. I configured both machines to use ssh and the necessary configurations for X11 forwarding in (/etc/ssh/sshd_config). in PC1 I have also to set DISPLAY variable:

export DISPLAY=localhost:0 

I want to ssh from PC1 to PC2 but I have one problem: The following command works fine:

ssh -Y username@PC2 gedit

it shows gedit on PC1 as expected. But when I ssh to PC2 then I start gedit:

$ ssh -Y username@PC2  # Now I am logged in to PC2
$ gedit

The GUI appears in PC2 instead of PC1

Could you please explain what's going wrong with the second way?

已采纳解答

原帖链接 · Ignacio Vazquez-Abrams · CC BY-SA 4.0

X forwarding over SSH is dependent on sshd setting the value of $DISPLAY appropriately, so forcing an override on the remote system will interfere. If you must set it regardless then only set it if it doesn't already have a value:

: ${DISPLAY:=:0}

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-06-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。