Ubuntu 14.04 安装配置 VNC 远程连接

一、背景

  由于 Ubuntu 14.04 采用的新版 Gnome 对远程桌面支持的非常不友好,因此,网上的解决方案普遍是安装旧版 gnome,或者安装 xfce 桌面,然后再开启 VNC 桌面,本文介绍的是前一种解决方案。

二、安装

# apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal vnc4server

三、配置

  新建配置文件输入以下内容:

# vim ~/.vnc/xstartup    

#!/bin/sh 
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
gnome-session &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &
vncconfig -nowin &

  给予可执行权限:

# chmod +x ~/.vnc/xstartup

  开启远程:

# vnc4server -geometry 1366x768

  关闭远程:

# vnc4server -kill :1    #必须指定桌面 ID 号,这里是:1,可通过进程看

四、附录

1、安装桌面环境

apt-get install gnome-shell
apt-get install ubuntu-gnome-desktop

2、安装中文语言

apt-get install language-pack-zh-hans

3、多用户 VNC

mkdir /opt/1404
vim /opt/1404/create_vnc_env.sh 

#!/bin/bash
# check system version

ver=`lsb_release -r | awk '{print $2}'`
if [ "$ver" != "14.04" ]; then
    echo "Error: This script can only work on Ubuntu 14.04"
    exit 0
fi
 
rm -rf ~/.vnc || echo "Error! Do not have permission to delete .vnc directory!"
rm -rf ~/.config/dconf
mkdir ~/.vnc
mkdir -p ~/.config/dconf

cat > ~/.vnc/xstartup <<eof
#!/bin/sh
    
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
  
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
  
gnome-session &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &
vncconfig -nowin &
eof

chmod +x ~/.vnc/xstartup
 
echo "Those VNC Desktop are already running:"
ps -ef | grep Xvnc | grep -v 'color=auto' | grep -v 'grep Xvnc' | awk '{printf "Desktop " $9 " belongs to " $12 "\n" }'
echo ""
echo ""
 
if [ -x ~/.vnc/xstartup ]; then
    echo "Done!"
    echo "start a VNC Desltop: vnc4server -geometry 1366x768 :1"
    echo "Stop a VNC Desktop:  vnc4server -kill :1"
else
    echo "Something error!"
fi

  给予执行权限:

chmod +x /opt/1404/create_vnc_env.sh

  让大家在开启 VNC 桌面前,先运行一次此脚本(只需要首次开启 VNC 桌面的时候运行一次),然后再开启 VNC 桌面就行了。


参考文章:
1、Ubuntu 14.04 安装配置 VNC 桌面


ArmxMod for Typecho
个性化、自适应、功能强大的响应式主题

推广

 继续浏览关于 ubuntuvnc远程连接 的文章

 本文最后更新于 2017/10/30 19:00:16,可能因经年累月而与现状有所差异

 引用转载请注明:VirCloud's Blog > 系统 > Ubuntu 14.04 安装配置 VNC 远程连接

精选评论

  1. karl

    x11vnc直接用unity.