Linux set up VNC

Ready to
turn off the firewall

systemctl stop firewalld
setenforce 0

1, yum install VNC server, easily solve the problem of dependence:

yum -y install tigervnc-server

And did not install a desktop option if the system is installed, then you need to use yum install what desktop, VNC is a remote graphical because:

yum groupinstall "X Window System" "Desktop"

2. Edit vnc configuration file
editing / etc / sysconfig / vncservers,
add the following:
centos6

vim /etc/sysconfig/vncservers
VNCSERVERS="1:root"VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared -depth 24"

centos7

vim /lib/systemd/system/vncserver@:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking  #[forking:root用户 simple:普通用户]
#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 || :'

Note: The resolution can be adjusted according to the actual situation, the resolution is improper connection may lead to vnc display a black screen phenomenon.

3. Set the VNC password
can be used to modify the command vncpasswd

vncpasswd

Here Insert Picture Description
Here Insert Picture Description
4. View vnc session information
to restart the vncserver service:
centos6

/etc/init.d/vncserver restart

centos7

systemctl daemon-reload
systemctl restart vncserver@:1.service
chmod 777 /root/.vnc/xstartup  #解决黑屏问题

View a vnc session information:

vncserver -list

5. Client vnc connection test
client is vncviewer, I have here is a Windows system

Enter 10.0.0.41:1, this is my vnc server IP
Here Insert Picture Description

After determining, prompted for a password, the password here is the vnc password,
Here Insert Picture Description
OK, you can connect to the server's desktop environment through vnc.

Here Insert Picture Description
When the above situation may be automatically put out screen

Here Insert Picture Description

Note: Here "10.0.0.41" is the server's IP address, while ": 1" corresponds VNCSERVERS configuration, this is the root user.

VNC personally think the biggest advantage is: the network suddenly disconnected, it will not affect the operation being done before.

Published 139 original articles · won praise 240 · views 10000 +

Guess you like

Origin blog.csdn.net/a13568hki/article/details/103921680