VNC(虚拟网络计算)服务器支持 Linux 系统的远程桌面访问,类似于MSTSC在窗户中。一般来说Linux管理员不喜欢使用Windows访问,但有时我们需要访问Linux的远程桌面。在这种情况下,我们需要在 Linux 系统上安装 vnc 服务器。本教程将帮助您进行设置VNC服务器并为用户配置远程访问CentOS, RHEL and Fedora Users.
第 1 步:安装所需的软件包
大多数 Linux 服务器的系统上没有安装桌面。因此,请确保您已经安装,否则使用以下命令来安装它。
For CentOS/RHEL 6:
# yum groupinstall "Desktop"
For CentOS/RHEL 5:
# yum groupinstall "GNOME Desktop Environment"
现在安装一些必需的软件包vnc服务器
# yum install pixman pixman-devel libXfont
第2步:安装VNC服务器
安装所需的软件包后,让我们安装vnc服务器在你的系统中。vnc服务器在默认 yum 存储库下可用。
# yum install vnc-server
On CentOS/RHEL 6,你会看到TigerVNC服务器将安装软件包。
步骤 3:创建 VNC 用户
让我们创建几个通过 vnc 连接的用户。也可以通过vnc连接来使用已有的系统用户,此时我们只需要设置vnc密码对于该帐户。
# useradd user1
# passwd user1
# useradd user2
# passwd user2
现在为所有需要通过 vnc 连接的帐户设置 vnc 密码。
# su - user1
$ vncpasswd
$ exit
# su - user2
$ vncpasswd
$ exit
步骤4:为用户配置VNC服务器
现在编辑/etc/sysconfig/vncservers配置文件并将以下内容添加到文件末尾。
VNCSERVERS="1:user1 2:user2"
VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[2]="-geometry 1024x768"
Where VNC服务器是需要连接的用户列表,VNC服务器定义屏幕尺寸。就像 user1 有一个800×600屏幕,以及user2 have 1024×768他的客户的屏幕尺寸。
现在使用以下命令启动 vnc-server 服务并检查输出
# service vncserver start
Starting VNC server: 1:user1 xauth: creating new authority file /home/user1/.Xauthority
New 'svr1.tecadmin.net:1 (user1)' desktop is svr1.tecadmin.net:1
Creating default startup script /home/user1/.vnc/xstartup
Starting applications specified in /home/user1/.vnc/xstartup
Log file is /home/user1/.vnc/svr1.tecadmin.net:1.log
2:user2 xauth: creating new authority file /home/user2/.Xauthority
New 'svr1.tecadmin.net:2 (user2)' desktop is svr1.tecadmin.net:2
Creating default startup script /home/user2/.vnc/xstartup
Starting applications specified in /home/user2/.vnc/xstartup
Log file is /home/user2/.vnc/svr1.tecadmin.net:2.log
[ OK ]
As per above output, you can see that user1 desktop is available on :1 and user2 desktop is available on :2. We will use :1 to connect to user1 and :2 to connect to user2.
步骤 5:使用 VNC 查看器连接 VNC 服务器
从远程访问Linux系统使用以下命令。
# vncviewer 192.168.1.11:1
访问 vnc-server 上的远程桌面视窗系统,您的系统上必须安装 vnc-viewer。有多种 vnc 查看器可供使用。下载任意一个并安装在您的系统上,例如:
紧VNC:http://www.tightvnc.com/download.php
真实VNC:https://www.realvnc.com/download/vnc/
老虎VNC:http://sourceforge.net/projects/tigervnc/files/tigervnc/
安装 vnc 查看器后连接到您的系统,在下面的示例中,我们连接到 user1 (:1)。
现在输入vnc密码分配给的帐户数vnc密码命令。
您已连接到 Linux 计算机的 x windows 系统。