CentOS 7.5 VNC配置

[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

===============================================================================================================================================================================================
 Package                                         Arch                                   Version                                        Repository                                         Size
===============================================================================================================================================================================================
Installing:
 tigervnc-server                                 x86_64                                 1.8.0-5.el7                                    CentOS-Repository                                 214 k

Transaction Summary
===============================================================================================================================================================================================
Install  1 Package

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.
  Installing : tigervnc-server-1.8.0-5.el7.x86_64                                                                                                                                          1/1 
  Verifying  : tigervnc-server-1.8.0-5.el7.x86_64                                                                                                                                          1/1 

Installed:
  tigervnc-server.x86_64 0:1.8.0-5.el7                                                                                                                                                         

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
#    parameters appropriately
#    (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
#     PIDFile=/home/<USER>/.vnc/%H%i.pid)
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, you should
# 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
# doing so through a secure tunnel.  See the "-via" option in the
# `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)
   Loaded: loaded (/etc/systemd/system/vncserver-root@.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-06-16 11:22:11 CST; 20s ago
  Process: 4159 ExecStart=/usr/sbin/runuser -l root -c /usr/bin/vncserver %i -geometry 1280x1024 (code=exited, status=0/SUCCESS)
  Process: 4152 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 4179 (Xvnc)
   CGroup: /system.slice/system-vncserver\x2droot.slice/vncserver-root@:1.service
           猓 4179 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop workplace:1 (root) -fp catalogue:/etc/X11/fontpath.d -geometry 1280x1024 -pn -rfbauth /root/.vnc/passwd -rfbport 5901 -r...

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.
[root@workplace selinux]# 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值