CENTOS7 Remote Desktop Vnc/vnc-server settings _linux

Source: Internet
Author: User
Tags iptables

Centos7 and centos6.x have a big difference.

In order to install Remote Desktop for a server, a lot of detours have gone. Write this blog, purely for the record, later if you encounter the same problem, can be traced back.

1, assuming that your system does not have any VNC software installed, then first install VNC

Yum-y Install Tigervnc-server Tigervnc

2, CENTOS7 before the system, if the installation VNC generally need to configure

[Root@localhost ~]# cat/etc/sysconfig/vncservers 
# This FILE has BEEN replaced by/lib/systemd/system/ Vncserver@.service

However, as noted above, CENTOS7 needs to configure the file in the

[Root@localhost ~]# ll/lib/systemd/system/vncserver@.service
-rw-r--r--. 1 root root 1744 June 14:15/lib/systemd/ System/vncserver@.service

3, the document has the following tips

# Quick HowTo:
# 1. Copy This file To/etc/systemd/system/vncserver@:<display>.service
# 2. Edit <USER> and Vncserver parameters appropriately
#  ("Runuser-l <USER>-c/usr/bin/vncserver%i-ar G1-arg2 ")
# 3. Run ' Systemctl daemon-reload '
# 4. Run ' Systemctl enable Vncserver@:<display>.service

4, copy a document, and renamed as Vncserver@:1.service

[root@localhost ~]# CP /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service

5, replace the <User> in the file with your current user, replace the%i with 1

[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:1 >/dev/null 2>&1 | |: '
Execstart=/sbin/runuser-l root-c "/usr/bin/vncserver:1-geometry 1280x720-depth"
pidfile=/root/.vnc/%h%i.pid
execstop=/bin/sh-c '/usr/bin/vncserver-kill:1 >/dev/null 2>&1 | |: '
[Install]
Wantedby=multi-user.target

6. Update Systemctl

Systemctl Daemon-reload

7. Set to start automatically

Systemctl Enable Vncserver@:1.service

8. Start VNC Service

Systemctl Start Vncserver@:1.service

9, add the corresponding port 5901 in the iptables (note that if you have other users, you also need to add the port.) VNC port defaults to 5900 + N)

[Root@localhost system]# cat/etc/sysconfig/iptables
# Sample configuration for iptables Service
# you can edit th are manually or use System-config-firewall # ' Please don't ask
us to add additional ports/services to this default conf Iguration
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m State- -state related,established-j ACCEPT
-a input-p icmp-j ACCEPT-a input-i lo-j ACCEPT
-a input-p tcp-m State--state new-m TCP--dport 22-j ACCEPT
-A input-p tcp-m State--state new-m TCP--dport 5901-j >-a input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with
COMMIT

Attention:

1, if you do not configure and enable firewall, at this time with VNC Viewer connection, will report: "Connect:connection timed out (10060)" error.

2, this article is based on the root user as an example, if other users also need to log in, then also need to copy the file as

CP /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:2.service

At the same time, the%i in the file is changed to 2 and the corresponding user's vncpasswd is established.

3, you can through the Ultravnc,tigervnc or RealVNC Viewer to visit, I win7 under the use of these 3 tools are able to connect

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.