VNC Linux 远程桌面控制软件

时间:2023-03-09 16:00:20
VNC Linux 远程桌面控制软件

简介:

VNC (Virtual Network Computer)是虚拟网络计算机的缩写。

VNC 是一款优秀的远程控制工具软件,VNC 是在基于 UNIX 和 Linux 操作系统的免费的开源软件,远程控制能力强大,高效实用,其性能可以和 Windows 和 MAC 中的任何远程控制软件媲美。

一、检查系统有没有安装 VNC

shell > rpm -qa | grep -i vnc
shell > ## 空的,NEXT

二、使用 YUM 安装 VNC

shell > yum -y install tigervnc tigervnc-server
shell > rpm -qa | grep -i vnc ## 安装成功
tigervnc-1.1.-.el6_5.x86_64
tigervnc-server-1.1.-.el6_5.x86_64

三、配置、启动 VNC

shell > vim /etc/sysconfig/vncservers
VNCSERVERS="1:root 2:wang" ## 配置远程桌面登陆的用户名,/ 为用户序号,用户间要有空格
VNCSERVERARGS[]="-geometry 1024x768" ## [] 为用户序号;指定分辨率为 1024x768
VNCSERVERARGS[]="-geometry 1024x768" 多用户分别指定 shell > vncserver : ## 为序号为 的用户启动 VNC
You will require a password to access your desktops.
Password: ## 启动必须为该用户设置 VNC 密码(vncpasswd 专门用于设置VNC密码)
Verify: 可惜我使用这个命令却没成功,不知道为什么
xauth: creating new authority file /root/.Xauthority
New 'localhost:1 (root)' desktop is localhost:
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost:.log
shell > netstat -anpt | grep vnc
tcp 0.0.0.0: 0.0.0.0:* LISTEN /Xvnc
tcp 0.0.0.0: 0.0.0.0:* LISTEN /Xvnc
tcp ::: :::* LISTEN /Xvnc

## 序号为 1 的VNC用户 root 监听的端口为 5901 ,多个用户以依次为 5902 、5903 ……( 规则为 5900+用户序号 )

shell > su - wang                               ## 必须切过去
[wang@localhost ~]$ vncserver : ## 为序号为 的用户启动 VNC、设置密码
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /home/wang/.Xauthority
New 'localhost:2 (wang)' desktop is localhost:
Creating default startup script /home/wang/.vnc/xstartup
Starting applications specified in /home/wang/.vnc/xstartup
Log file is /home/wang/.vnc/localhost:.log
[wang@localhost ~]$ netstat -anpt | grep vnc
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0.0.0.0: 0.0.0.0:* LISTEN /Xvnc
tcp 0.0.0.0: 0.0.0.0:* LISTEN /Xvnc
tcp ::: :::* LISTEN /Xvnc

## 序号为 2 的VNC用户 wang 所监听的端口为 5902

[wang@localhost ~]$ exit

## vncserver : 或 :        启动某个用户的 VNC(如不是当前用户需 su - 到这个用户)
vncserver -kill : 或 : 关闭某个用户的 VNC(如不是当前用户需 su - 到这个用户)
vncserver -list 查看当前登陆用户有没有开启 VNC (如不是当前用户需 su - 到这个用户)
service vncserver start|stop|restart 开启、关闭服务(所有用户的 VNC) shell > chkconfig --add vncserver ## VNC 加入开机启动
shell > chkconfig --level vncserver on

四、防火墙允许 VNC 通过

shell > vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT

## 也可以使用 iptables 命令添加,如果你只开一个 VNC 则只允许 5901 即可

shell > service iptables restart   ## 重启防火墙使规则生效

五、Windows 客户端测试

VNC Viewer for Windows 下载地址 http://www.realvnc.com/download/binary/1613/

客户端 VNC Server: 处输入 IP:1 、IP:2 如 :192.168.1.80:1 等 然后输入该用户 VNC 密码