CentOS 7.5 VNC配置

匿名 (未验证) 提交于 2019-12-02 23:43:01

[root@workplace selinux]# setenforce 0
[root@workplace selinux]# systemctl stop firewalld

[root@workplace yum.repos.d]# yum install tigervnc-server -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.x86_64 0:1.8.0-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================

===============================================================================================================================================================================================
Installing:

Transaction Summary
===============================================================================================================================================================================================

Total download size: 214 k
Installed size: 508 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.

Installed:

Complete!
[root@workplace yum.repos.d]


[root@workplace selinux]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-root@.service
[root@workplace selinux]# vi /etc/systemd/system/vncserver-root@.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@.service
# 2. Replace <USER> with the actual user name and edit vncserver



# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is

# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# Use "-localhost" to prevent remote VNC clients connecting except when

# `man vncviewer' manual page.


[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=root

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
#ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024"
PIDFile=/root/.vnc/%H%i.pid
#ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStop=-/usr/bin/vncserver -kill %i

"/etc/systemd/system/vncserver-root@.service" 51L, 1954C written
[root@workplace selinux]# systemctl daemon-reload
[root@workplace selinux]# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
[root@workplace selinux]# systemctl start vncserver-root@:1.service
[root@workplace selinux]# systemctl status vncserver-root@:1.service
?vncserver-root@:1.service - Remote desktop service (VNC)






Jun 16 11:22:07 workplace systemd[1]: Starting Remote desktop service (VNC)...
Jun 16 11:22:11 workplace systemd[1]: Started Remote desktop service (VNC).
[root@workplace selinux]# systemctl enable vncserver-root@:1.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vncserver-root@:1.service to /etc/systemd/system/vncserver-root@.service.

文章来源: https://blog.csdn.net/openeis/article/details/92382899
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!