How to install and access CentOS 7 Remote Desktop on VPS

Source: Internet
Author: User
Tags vps

How to install and access CentOS 7 Remote Desktop on VPS

Q: I want to install CentOS desktop in VPS and can remotely access the GUI desktop from my home. Is there any suggestions for setting and accessing CentOS Remote Desktop on VPS?

How to work remotely or remotely with elasticity is becoming increasingly popular in the technical field. One technology behind this trend is Remote Desktop. Your desktop environment is in the cloud. You can access your remote desktop anywhere you go, or at home or in the workplace.

This tutorial describes how to set up a CentOS-based Remote Desktop in VPS. Now, we will first display the Basic Environment of CentOS.

Assume that you have created a VPS instance for CentOS 7 (for example, DigitalOcean or Amazon EC2 ). Make sure that your VPS instance has at least 1 GB of memory. Otherwise, CentOS will crash when you access the Remote Desktop.

 

Step 1: Install CentOS Desktop

If the CentOS version you have installed does not have the minimum desktop version, you must first install the desktop (such as GNOME) on the VPS ). For example, the image of DigitalOcean is the minimum version, and it needs to install the desktop GUI as follows:

  1. # yum groupinstall "GNOME Desktop"

After the installation is complete, restart the VPS.

 

Step 2: install and configure the VNC Server

Next, install and configure the VNC server. We use TigerVNC, an open-source VNC service implementation.

  1. # yum install tigervnc-server

Create a user account (for example, xmodulo) to access the Remote Desktop.

  1. # useradd xmodulo
  2. # passwd xmodulo

When a user tries to use VNC to access the remote desktop, the VNC daemon starts to process the request. This means that you need to create an independent VNC configuration file for each user.

CentOS relies on systemd to manage and configure system services. Therefore, we will use systemd to configure the VNC Server for xmodulo.

First, let's use any of the following commands to check the status of the VNC server.

  1. # systemctl status vncserver@:.service
  2. # systemctl is-enabled vncserver@.service

By default, the installed VNC service is not activated (disabled ).

Copy a common VNC service file to create a VNC service configuration for xmodulo.

  1. # cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

Use the editor in this article to open the configuration file and replace the configuration file with the actual user name (for example, xmodulo) under [Service. Same. Append the "-geometry" parameter after ExecStart. Finally, modify the following "ExecStart" and "PIDFile" lines.

  1. # vi /etc/systemd/system/vncserver@:1.service
  1. [Service]
  2. Type=forking
  3. # Clean any existing files in /tmp/.X11-unix environment
  4. ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
  5. ExecStart=/sbin/runuser -l xmodulo -c "/usr/bin/vncserver %i -geometry 1024x768"
  6. PIDFile=/home/xmodulo/.vnc/%H%i.pid
  7. ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

Set the password for xmodulo (optional ). Switch to the user and run the vncserver command.

  1. # su - xmodulo
  2. # vncserver

You will be prompted to enter your VNC password. After the password is set, you need to use this password to access your remote desktop next time.

Finally, reload the service to make the new VNC configuration take effect:

  1. # systemctl daemon-reload

The VNC service is automatically started at startup:

  1. # systemctl enable vncserver@:1.service

Check the port on which the vnc service is listening:

  1. # netstat -tulpn | grep vnc

Port 5901 is the default port used by the VNC client to connect to the VNC server.

 

Step 3: connect to the Remote Desktop through SSH

In terms of design, the remote frame cache (RFB) used by VNC is not a secure protocol, so it is not a good idea to connect directly to the VNC server on the VNC client. Any sensitive information, such as passwords, can be easily disclosed in VNC traffic. Therefore, I strongly recommend using an SSH tunnel to encrypt your VNC traffic.

On the local machine where you want to run the VNC client, use the following command to create an SSH channel to connect to the remote VPS. Enter the SSH password.

  1. $ ssh xmodulo@<VPS-IP-address>-L 5901:127.0.0.1:5901

Replace "xmodulo" with your own VNC user name and fill in your own vps ip address.

Once the SSH channel is established, the remote VNC traffic is routed through the ssh channel and sent to 127.0.0.1: 5901.

Start your favorite VNC client (such as vinagre) to connect to 127.0.0.1: 5901.

You will be asked to enter the VNC password. When you enter the VNC password, you can Securely connect to the CentOS Remote Desktop.

Then you will see the display of the question map.

Related Article

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.