Skip to content

Linux GUI X11转发

步骤

  1. 客户端(本机)开启X Server
  2. 服务器(SSH目标)设置$DISPLAY环境变量
  3. 直接执行带X图形界面的程序

最简单的方法

直接使用MobaXTerm

Windows

JetBrains IDE调试显示图形界面

macOS

XQuartz官网

  1. (macOS本机)使用HomeBrew安装xquartz
brew install --cask xquartz

# 启动xquartz,实测`Allow connections from clients`选项非必须条件
Run Applications > Utilities > XQuartz.app
  1. (macOS本机)连接远程服务器
# ssh添加-Y flag登录远程主机
ssh -Y user@host
  1. (Linux服务器)在SSH会话中设置环境变量,默认为:0
# 设置DISPLAY环境变量
export DISPLAY=:0
  1. (Linux服务器)运行X图形界面程序
xclock
# or
xeyes

Ref

https://www.wuweixin.com/2022/02/23/macos-install-and-using-xquartz/ https://blog.csdn.net/u011074091/article/details/135940020 https://zhuanlan.zhihu.com/p/311227197