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 configure VNC in CentOS to realize remote login access

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "how to configure VNC in CentOS to achieve remote login access", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to configure VNC in CentOS to achieve remote login access" bar!

The VNC server is configured below so that the user (root) can remotely connect to the terminal or graphical interface of the CentOS system through the vnc client.

1. Check whether VNC is installed on the CentOS system, and enter:

# rpm-Q vnc-server

If it is not installed, run the following command to install:

# yum install vnc vnc-server

2. Start the VNC service:

# vncserver

You will require a password to access your desktops.

Password:

Verify:

You will be prompted for a password, which is the password you need to enter when logging in remotely.

3. Edit the VNC configuration file: (press I to enter the editing state, press ESC to exit the editing state, Shift+ colon and enter wq, save and exit)

Vi / etc/sysconfig/vncservers / / Edit VNC configuration file

# VNCSERVERS= "1:root" / / remove # and configure the desktop number and user name according to the actual configuration

# VNCSERVERARGS [2] = "- geometry 1024x768-nolisten tcp-localhost" / / remove #, configure resolution

Save exit after modification

4. Configure the firewall to allow the port corresponding to the desktop number (the desktop number is 1, then the connection port number of the vnc is 59001room5901, and so on) through the firewall:

# vi / etc/sysconfig/iptables / / Edit Firewall configuration File

-A RH-Firewall-1-INPUT-m state-- state NEW-m tcp-p tcp-- dport 5901-j ACCEPT / / allow access from port 5901 to pass through the firewall

Save exit

5. Restart the VNC server and firewall:

/ etc/init.d/vncserver restart or service vncserver restart / / restart the VNC server

/ etc/init.d/iptables restart or service iptables restart / / restart the firewall

6. Set the vnc server to start automatically when it starts:

Method 1: use the "ntsysv" command to start the graphical service configuration program, select the vncserver service, and click OK.

Method 2: use the chkconfig command in the terminal:

# chkconfig vncserver on

# chkconfig-list vncserver

Vncserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off

7. Change the VNC connection password: (or not)

# vncpasswd

At this point, the VNC server is basically completed. You can remotely log in to CentOS using a VNC client (such as RealVNC):

Input: CentOS system IP:5901 (for example, enter: 192.168.1.100 RealVNC 9501)

You will then be prompted for a password.

8. If a gray screen appears after the connection or only the terminal (command line) does not enter the graphical interface (when the graphical interface is installed), you can set it as follows:

Enter the user's home directory, cd / home/user

If you are logged in with a root account, then the current directory is the user root directory

# cd ~ / .vnc

Vi xstartup / / Edit xstartup configuration

# twm & / / add # to comment out this line

Gnome-session & / / add this line

Save and exit to connect normally!

Thank you for your reading, the above is the content of "how to configure VNC in CentOS to achieve remote login access". After the study of this article, I believe you have a deeper understanding of how to configure VNC in CentOS to achieve remote login access, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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