CentOS 7.4 VNC-TIGERVNC配置

CentOS 7.x上的VNC很多配置文档都不完全正确,主要是不能完全显示图形界面。


如果我们能够安装redhat entprise Linux 7.x的官方文档配置就没有这个问题了。


下面是根据redhat entprise Linux 7.x的官方文档做的实验。


[root@compute1 ~]# yum installtigervnc-server -y





Installed:

tigervnc-server.x86_640:1.8.0-1.el7



Complete!

[root@compute1 ~]# cat/lib/systemd/system/[email protected]

# The vncserver service unitfile

#

# Quick HowTo:

# 1. Copy this file to/etc/systemd/system/[email protected]

# 2. Replace <USER> withthe actual user name and edit vncserver

# parameters appropriately

# ("User=<USER>"and "/home/<USER>/.vnc/%H%i.pid")

# 3. Run `systemctldaemon-reload`

# 4. Run `systemctl enablevncserver@:<display>.service`

#

# DO NOT RUN THIS SERVICE ifyour local area network is

# untrusted! For a secure wayof using VNC, you should

# limit connections to thelocal host and then tunnel from

# the machine you want to viewVNC on (host A) to the machine

# whose VNC output you want toview (host B)

#

# [user@hostA ~]$ ssh -v -C -L590N:localhost:590M hostB

#

# this will open a connectionon port 590N of your hostA to hostB's port 590M

# (in fact, it ssh-connects tohostB and then connects to localhost (on hostB).

# See the ssh man page fordetails on port forwarding)

#

# You can then point a VNCclient on hostA at vncdisplay N of localhost and with

# the help of ssh, you end upseeing 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 securetunnel. See the "-via" option in the

# `man vncviewer' manual page.





[Unit]

Description=Remote desktopservice (VNC)

After=syslog.targetnetwork.target



[Service]

Type=forking

User=<USER>



# Clean any existing files in/tmp/.X11-unix environment

ExecStartPre=-/usr/bin/vncserver-kill %i

ExecStart=/usr/bin/vncserver%i

PIDFile=/home/<USER>/.vnc/%H%i.pid

ExecStop=-/usr/bin/vncserver-kill %i



[Install]

WantedBy=multi-user.target

[root@compute1 ~]# cp/lib/systemd/system/[email protected]/etc/systemd/system/[email protected]

[root@compute1 ~]# vi/etc/systemd/system/[email protected]

# The vncserver service unitfile

#

# Quick HowTo:

# 1. Copy this file to/etc/systemd/system/[email protected]

# 2. Replace <USER> withthe actual user name and edit vncserver

# parameters appropriately

# ("User=<USER>"and "/home/<USER>/.vnc/%H%i.pid")

# 3. Run `systemctldaemon-reload`

# 4. Run `systemctl enablevncserver@:<display>.service`

#

# DO NOT RUN THIS SERVICE ifyour local area network is

# untrusted! For a secure wayof using VNC, you should

# limit connections to thelocal host and then tunnel from

# the machine you want to viewVNC on (host A) to the machine

# whose VNC output you want toview (host B)

#

# [user@hostA ~]$ ssh -v -C -L590N:localhost:590M hostB

#

# this will open a connectionon port 590N of your hostA to hostB's port 590M

# (in fact, it ssh-connects tohostB and then connects to localhost (on hostB).

# See the ssh man page fordetails on port forwarding)

#

# You can then point a VNCclient on hostA at vncdisplay N of localhost and with

# the help of ssh, you end upseeing 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 securetunnel. See the "-via" option in the

# `man vncviewer' manual page.





[Unit]

Description=Remote desktopservice (VNC)

After=syslog.targetnetwork.target



[Service]

Type=forking

User=root



# Clean any existing files in/tmp/.X11-unix environment

ExecStartPre=-/usr/bin/vncserver-kill %i

#ExecStart=/usr/bin/vncserver%i

ExecStart=/usr/sbin/runuser-l root -c "/usr/bin/vncserver %i -geometry 1280x1024"

PIDFile=/root/.vnc/%H%i.pid

ExecStop=-/usr/bin/vncserver-kill %i



[Install]

"/etc/systemd/system/[email protected]"49L, 1754C written

[root@compute1 ~]# systemctldaemon-reload

[root@compute1 ~]# vncpasswd

Password:

Verify:

Would you like to enter aview-only password (y/n)? n

[root@compute1 ~]#





To start or enable theservice, specify the display number directly in the command. The fileconfigured

above in Procedure 12.1,“Configuring a VNC Display for a Single User” works as atemplate, in which %i

is substituted with thedisplay number by systemd. With a valid display number, execute thefollowing

command:





~]# systemctl startvncserver@:display_number.service









[root@compute1~]# systemctl start [email protected]

Failedto start [email protected]: Unit name [email protected] missing the instance name.

Seesystem logs and 'systemctl status [email protected]' fordetails.

[root@compute1~]# systemctl start vncserver-root@:1.service

[root@compute1~]#





You can also enable theservice to start automatically at system start. Then, when you login,

vncserver is automaticallystarted. As root, issue a command as follows:

~]# systemctl enablevncserver@:display_number.service



[root@compute1~]# systemctl enable vncserver-root@:1.service

Createdsymlink from/etc/systemd/system/multi-user.target.wants/vncserver-root@:1.serviceto /etc/systemd/system/[email protected].

[root@compute1~]#





VNC Viewer访问VNC服务器



在输入框中输入“IP地址:display_number”。如下所示:



192.168.226.31:1







猜你喜欢

转载自blog.csdn.net/openeis/article/details/80048655