Centos7:
- 安装依赖文件:
yum install xorg-x11-xauth xorg-x11-fonts-* xorg-x11-font-utils xorg-x11-fonts-Type1 xclock
- 修改参数,启用X11 Forwarding
vi /etc/ssh/sshd_config
修改参数X11Forwarding和X11UseLocalhost#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
X11UseLocalhost no
重启sshd服务systemctl restart sshd.service
使用MobaXterm重新登录,登录之后会显示:• X11-forwarding : ✓ (remote display is forwarded through SSH) 表示启用成功
运行xclock会弹出一个时钟
Ubuntu:
ubuntu上比较简单,直接安装:apt install x11-apps,就会把相关依赖都安装上,然后修改sshd的配置,跟centos一样,修改X11Forwarding和X11UseLocalhost
然后重启ssh:/etc/init.d/ssh restart