Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and use CentOS remote Desktop on a VPS Host

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to install and use CentOS remote Desktop on VPS host". In daily operation, I believe many people have doubts about how to install and use CentOS remote desktop on VPS host. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how to install and use CentOS remote desktop on VPS host". Next, please follow the editor to study!

How to telecommute or work remotely is becoming more and more popular in the technical field. One technology behind this trend is remote desktops. Your desktop environment is in the cloud, and you can access your remote desktop wherever you go, at home or in the workplace.

This tutorial describes how to set up CentOS-based remote desktops in VPS. Now, we will first show the basic environment of CentOS.

Let's assume that you have created a VPS instance of CentOS 7 (for example, using DigitalOcean or Amazon EC2). Please make sure that your VPS instance has at least 1GB memory. Otherwise, CentOS will crash when you access remote desktops.

Step 1: install CentOS Desktop

If you are installing a minimum version of CentOS without a desktop, you need to install desktops (such as GNOME) on VPS first. For example, the image of DigitalOcean is the minimum version, which requires the following installation of desktop GUI

The code is as follows:

# yum groupinstall "GNOME Desktop"

Restart VPS after the installation is complete.

Step 2: install and configure the VNC server

The next step is to install and configure VNC server. We are using TigerVNC, an open source VNC service implementation.

The code is as follows:

# yum install tigervnc-server

Now create a user account (for example: xmodulo) to access remote desktops.

The code is as follows:

# useradd xmodulo

# passwd xmodulo

When a user tries to access a remote desktop using VNC, the VNC daemon starts to process the request. This means that you need to create a separate VNC profile for each user.

CentOS relies on systemd to manage and configure system services. So we will use systemd to configure the VNC server for the user xmodulo.

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

The code is as follows:

# systemctl status vncserver@:.service

# systemctl is-enabled vncserver@.service

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

Now copy a generic VNC service file to create a VNC service configuration for the user xmodulo.

The code is as follows:

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

Open the configuration file with the article editor and replace the one under [Service] with the actual user name (for example: xmodulo). same. Append the "- geometry" parameter after ExecStart. Finally, modify the following lines "ExecStart" and "PIDFile".

The code is as follows:

# vi / etc/systemd/system/vncserver@:1.service

[Service]

Type=forking

# 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 xmodulo-c "/ usr/bin/vncserver% I-geometry 1024x768"

PIDFile=/home/xmodulo/.vnc/%H%i.pid

ExecStop=/bin/sh-c'/ usr/bin/vncserver-kill% I > / dev/null 2 > & 1 | |:'

Now set the password for the user xmodulo (optional). First switch to that user and run the vncserver command.

The code is as follows:

# su-xmodulo

# vncserver

You will be prompted to enter the user's 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 effective:

The code is as follows:

# systemctl daemon-reload

Start the VNC service automatically at startup:

The code is as follows:

# systemctl enable vncserver@:1.service

Check the port on which the vnc service is listening:

# netstat-tulpn | grep vnc

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

Step 3: connect to the remote Desktop through SSH

By 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 SSH tunnels to encrypt your VNC traffic.

On the local machine where you want to run the VNC client, use the following command to create a SSH channel to connect to the remote VPS. When the SSH password is to be entered, enter the user's password.

The code is as follows:

$ssh xmodulo@-L 5901 purl 127.0.0.1 purl 5901

Replace "xmodulo" with your own VNC user name and fill in your own VPS IP address.

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

Now start your favorite VNC client (for example: vinagre) to connect to 127.0.0.1 5901.

You will be asked to enter your VNC password. When you enter your VNC password, you can securely connect to CentOS's remote desktop.

Then you will see the display as shown in the picture.

At this point, the study on "how to install and use CentOS remote Desktop on a VPS host" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report