环境
Windows10+CentOS7.4
软件
服务器端:VNC-server
控制端:VNC-view
步骤
一、服务器端(CentOS)
1、在root下执行
yum install -y tigervnc-server(下载VNCSERVER)
2、配置vnc-server
首先,进入目录
cd /lib/systemd/system
复制该service,命名为vncserver@:1.service
cp vncserver@.service vncserver@:1.service
然后修改vncserver@:1.service
vi vnserver@:1.service
将文本里面的<user>更改为root(前提是你现在是root用户)
更改后如下
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l root -c “/usr/bin/vncserver %i ”
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
[Install]
WantedBy=multi-user.target
3.配置完成后
systemctl daemon-reload
systemctl enable vncserver@:1.service
然后开启vnc服务
systemctl start vncserver@:1.service
查看是否启动成功
systemctl status vncserver@:1.service
如何显示active即开启成功,但这个时候一般都是fail
因为你需要关闭防火墙
//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld
在重复一下上面的操作,若还是fail,就重启一边再开启,这个时候应该就会显示active了
输入vncserver
输入你的密码,查看你的端口号
如:
You will require a password to access your desktops.
Password:
Verify:
xauth: file /home/admin/.Xauthority does not exist
New ‘localhost.localdomain:2 (admin)’ desktop is localhost.localdomain:2
Creating default startup script /home/admin/.vnc/xstartup
Starting applications specified in /home/admin/.vnc/xstartup
Log file is /home/admin/.vnc/localhost.localdomain:2.log
你的端口号为2
在你的Window端(vnc-viewer)
连接即可
4.看下效果