说明:
通过vncserver我们可以开启远程服务器的图形化桌面,如运行vncserver :1则打开了一个桌面号为1的远程图形化桌面,然后执行vncviewer server1.example.com:1就可以访问该桌面,从而执行一些必须在图形化下才能执行的操作,而且可以多个用户同时登录该桌面,方便协同合作。
但是这个方法无法把在本地登录的桌面($DISPLAY==:0.0)共享出去,执行vncserver :0会报如下错误。windows下的netmeeting/communicator有类似的共享功能,linux下则可以借助x11vnc来实现。
┌─[liao@tp]─[~/bin]─[18+5]─[99%=]
└─$ vncserver :0
You will require a password to access your desktops.
Password:
Verify:
Warning: tp:0 is taken because of /tmp/.X0-lock
Remove this file if there is no X server tp:0
A VNC server is already running as :0
┌─[✗]─[liao@tp]─[~/bin]─[18+5]─[99%=]
└─$
安装:
sudo pacman -S x11vnc
执行:
默认情况下,通过x11vnc共享桌面后,观众也能操作我们的机器,不过我们也能让x11vnc运行viewonly模式下,这样观众就只能看我们操作了。
#!/bin/bash
killall -9 x11vnc
#/usr/bin/x11vnc -nap -wait 50 -noxdamage -passwd x11vnc -display :0 -forever -o ~/.vnc/x11vnc.log -rfbport 9500 -bg
if test "$1" == "vo"; then
# viewonly
/usr/bin/x11vnc -nap -wait 50 -noxdamage -passwd x11vnc -display :0 -forever -o ~/.vnc/x11vnc.log -rfbport 9500 -viewonly -bg && \
echo "x11vnc has been running in VIEWONLY mode"
else
# interactive
/usr/bin/x11vnc -nap -wait 50 -noxdamage -passwd x11vnc -display :0 -forever -o ~/.vnc/x11vnc.log -rfbport 9500 -bg && \
echo "x11vnc has been running in INTERACTIVE mode"
fi
测试:
vncviewer server1.example.com:9500
X11VNC在Ubuntu 14.04服务器版上开启远程桌面的使用:http://www.linuxdiyf.com/linux/10447.html
X11VNC:让Windows可以远程管理Ubuntu桌面:http://www.linuxdiyf.com/linux/3343.html