ssh usage record
SSH X11 Forwarding Guide
# Server configuration (remote host)
# Edit SSH profile
sudo nano /etc/ssh/ssh_config
# # Ensure the following arguments are set to yes (unannotation and modified)
X11Forwarding yes
X11DisplayOffset 10
# Open this configuration only via localhost, Other IP connections will fail
X11UseLocalhost no
# This view needs to configure
AddressFamily inet # to force IPv4 (avoid IPv6 conflict)
# Restart SSH service to take account of the configuration
sudo systemctl start sshd
# Client connection (local computer)
# Base command (-X:Secure Mode, -Y:Trust Mode)
ssh -Y username@remote server IP
# Example:connection host
ssh -Y alice@192.168.1100
# After a successful connection, enter graphics program name in remote terminals with sufficient:
# Test command (server is required to install x11-apps)
xclock # Display a simple clock window (verify X11 works)
xeyes# show the eye animation
geedit # start text editor
firefox # run browser (remote render, local show)
# Required and troubleshoot
# Server side dependencies
# Installing X11 related tools (Ubuntu/Debian )
sudo apt install xauth x11-apps
# Advanced skills
# # compressed transfer:enable compression (-C parameter):
ssh -YC username@remote IP # -Y trust mode + -Ccompression
# Multiwindow management:in conjunction with screen or tmux, Reconnect to SSH to restore window.
# Mac客户端配置(关键步骤)
# 1. 安装XQuartz(Mac必备X服务器)
brew install --cask xquartz
# 2. 启动XQuartz并配置
open -a XQuartz
# 在XQuartz偏好设置→安全性中勾选"允许从网络客户端的连接"
# 3. 重启终端后重新连接
ssh -Y pdd.intranet.company
# 4. 验证DISPLAY变量
echo $DISPLAY # 应显示类似 localhost:10.0
# Firefox打不开窗口的问题
# 方式一: 允许Snap访问X11(推荐)
# 给Firefox snap添加X11权限
sudo snap connect firefox:x11
# 然后重新启动Firefox
firefox
# 方式二: 使用非Snap Firefox
# 先停止当前的snap firefox
sudo snap remove firefox
# 安装deb版本的firefox
sudo apt update
sudo apt install firefox
# 测试
firefox
# 方法3:临时绕过Snap限制
# 使用--no-sandbox参数启动
firefox --no-sandbox
# 或者设置环境变量
export MOZ_DISABLE_CONTENT_SANDBOX=1
firefox
# 方法4:使用其他浏览器测试
# 安装并测试Chromium
sudo apt install chromium-browser
chromium-browser
# chromium-browser打不开窗口的问题
# 修复缺失的共享库
# 安装X11基础依赖库(覆盖libpxbackend相关组件)
sudo apt update && sudo apt install -y \
libx11-dev libxext-dev libxrender-dev \
libxtst-dev libxi-dev libxrandr-dev \
libgl1-mesa-glx libglu1-mesa
# 检查库文件是否存在
sudo find /usr/lib -name "libpxbackend*"
# 为Chromium添加X11权限
sudo snap connect chromium:x11
# 验证权限是否生效
snap interfaces | grep chromium:x11
# 方法5:检查DISPLAY和XAUTHORITY变量
echo $DISPLAY $XAUTHORITY
export DISPLAY=localhost:10.0
chromium-browser --no-sandbox --disable-setuid-sandbox
# 方法6:完全绕过Snap限制
# 方法A:安装Firefox ESR(非Snap)
sudo apt update
sudo apt install firefox-esr
firefox-esr
# 方法B:安装Chromium deb版本
sudo apt install chromium-browser
# 方法C:安装其他轻量级浏览器
sudo apt install epiphany-browser # GNOME Web
sudo apt install midori
# 完全绕过Snap限制
# 临时禁用Snap安全特性
sudo snap set core experimental.xdg-desktop-portal=false
# 或者使用--no-sandbox
chromium-browser --no-sandbox --disable-setuid-sandbox
sudo apt install libgtk-3-0 # 确保GTK库完整
# 移除 Snap 版 Firefox:
sudo snap remove firefox
# 添加 Mozilla 官方 PPA 源:
sudo add-apt-repository ppa:mozillateam/ppa
# 设置优先级(防止系统自动装回 Snap): 执行以下命令创建一个配置文件:
echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozilla-firefox
# 安装原生 Firefox:
sudo apt update
sudo apt install firefox
# 使用独立模式启动 (推荐)
firefox --no-remote --new-instance
# 或者,如果还是报错,可以尝试指定一个新的 Profile:
firefox -P
# 重启 Firefox 确保 Profile 生效
sudo killall -9 firefox
firefox --no-remote
# 创建新配置文件
firefox -CreateProfile "newprofile"
# 使用新配置文件启动
firefox -P "newprofile"
# 赋予 Snap 特权权限(不一定成功)
sudo snap refresh firefox --channel=stable/pkg-testing
# 注意:即便如此,Snap 在处理 X11 转发路径(如 /tmp/.X11-unix)时依然经常出错。
# Processing OpenGL/Graphics Warning (optional)
# Installing OpenGL and Mesa Gallery
sudo apt update
sudo apt install - y mesa-utils libgl1-mesa-dri libglx-mesa 0
# Verify Graph Configuration (unnecessary, Used for confirmation)
glxinfo | grep "direct rendering" # output "direct rendering: Yes" means normal
# Install Google Chrome (non-Snap version)
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64. eb
google-chrome --no-sandbox
# Force new instance: (this will assign Chrome a temporary folder to store data and avoid all permissions conflicts.)
google-chrome -user-data-dir=/tmp/chrome-remote --no-sandbox
# --disable-gpu: in remote SSH environment, Accelerate with hardware to significantly improve stability and reduce flash back.
google-chrome --no-sandbox --user-data-dir=/tmp/chrome_test --disable-gpu
# Method 4:Use VNC
# to start VNC server
vncserver :1 -geometry 1920x1080 - depth 24
# Connect from Mac
open vnc://master1:5901