1.安装必要的软件
apt-get -y install ubuntu-desktop tightvncserver xfce4 xfce4-goodies
2.增加VNC用户及密码
adduser vnc passwd vnc
为VNC设置Root权限(前提是以Root用户登录)
echo "vnc ALL=(ALL) ALL" >> /etc/sudoers
3.设置vnc的VNC Server密码
su - vnc vncpasswd exit
4.把VNC作为系统服务
编辑/etc/init.d/vncserver加入以下文本
#!/bin/bash PATH="$PATH:/usr/bin/" export USER="vnc" DISPLAY="1" DEPTH="16" GEOMETRY="1024x768" OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}" . /lib/lsb/init-functions case "$1" in start) log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "/usr/bin/vncserver ${OPTIONS}" ;; stop) log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}" ;; restart) $0 stop $0 start ;; esac exit 0
编辑/home/vnc/.vnc/xstartup并将其替换为如下内容
#!/bin/sh xrdb $HOME/.Xresources xsetroot -solid grey startxfce4 &
更新文件权限,使得其他用户也能启动VNC服务
chown -R vnc. /home/vnc/.vnc && chmod +x /home/vnc/.vnc/xstartup sed -i 's/allowed_users.*/allowed_users=anybody/g' /etc/X11/Xwrapper.config
使/etc/init.d/vncserver可运行并启动VNC Server:
chmod +x /etc/init.d/vncserver && service vncserver start
修改VNC为自动启动
update-rc.d vncserver defaults
5.使用TightVNC进行远程连接
链接方法,Remote Host的地方填写【你的ip::5901】,点击Connect后输入你刚才设置的密码。如果没有错误,xfce那只小老鼠就出来了~