VNC (Virtual Network Console)是虚拟网络控制台的缩写。它 是一款优秀的远程控制工具软件, 主要由两部分组成:一部分是客户端的应用程序(vncviewer),另外一部分是服务器端的应用程序vncserver。
1 VNC Server
# 安装vnc服务端
apt-get install tigervnc-standalone-server
# 启动vnc服务端
vncserver -geometry 1920x1080 -localhost no
# 定义vnc连接服务端所需的Password,如123123
出现如下信息则表示启动了一个虚拟桌面:
New 'user-pc:1 (root)' desktop at :1 on machine user-pc
Starting applications specified in /etc/X11/Xvnc-session
Log file is /root/.vnc/user-pc:1.log
Use xtigervncviewer -SecurityTypes VncAuth -passwd /root/.vnc/passwd :1 to connect to the VNC server.
# 补充:关闭vncserver的命令
vncserver -kill :1
2 VNC Viewer
VNC Viewer连接VNC Server:
File -> New connection... -> General
VNC Server: 10.201.52.63:5901
之后即可通过此5901
端口进行连接访问。
启动多个虚拟桌面
如果再次执行 vncserver -geometry 1920x1080 -localhost no
,则可通过5902
端口访问,以此类推。
New 'user-pc:2 (root)' desktop at :2 on machine user-pc
Starting applications specified in /etc/X11/Xvnc-session
Log file is /root/.vnc/user-pc:2.log
Use xtigervncviewer -SecurityTypes VncAuth -passwd /root/.vnc/passwd :2 to connect to the VNC server.
3 问题
在龙芯服务器上安装VNC使,遇到了VNC viewer连接成功后显示灰色的问题,这时需要更改服务端配置文件(若没有则创建) ~/.vnc/xstartup
,添加如下内容:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
#unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
#[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
# x-window-manager &
mate-session &
#!/bin/sh
# Uncomment the following two lines for normal desktop:
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
gnome-panel &
gnmoe-settings-daemon &
metacity &
nautilus &
gnome-terminal &