在服务器上使用xvfb创建虚拟桌面
export DISPLAY=:1
Xvfb :1 -screen 0 1024x768x16 &
使用x11vnc发布这一桌面
x11vnc -display :1 -bg -nopw -listen localhost -xk
在客户机(自己的电脑)上使用vncviewer
ssh -N -T -L 5900:localhost:5900 user@remotehost &
vncviewer -encodings 'copyrect tight zrle hextile' localhost:5900
或者
x11vnc -display :1 -ncache -rfbauth ~/.vnc/passwd -rfbport 4024 -forever -shared &
第1块虚拟屏幕,cache不变的像素,使用passwd文件里存储的密码(x11vnc -storepasswd **** .vnc/passwd),端口改成4024,forever表示链接后不退出,shared表示可同时多人打开
然后可以在当前命令行下用matlab等需要gui的程序: matlab
vncviewer localhost:4024
PS.
x11vnc -R command 可以向跑着的程序发送命令,比如shared允许多人链接
可以配合fluxbox实现一个轻量的桌面系统,以便打开的应用有边框。