Original URL: https://help.aliyun.com/knowledge_detail/41181.html?spm=5176.8208715.110.11.4c184ae8mlC7Yy
You can use the script provided in this article to automatically install and run VNC server on a Linux instance for remote graphical management of the Linux server. Currently, the script is only available for CentOS instances and will install the GNOME desktop environment in the CentOS instance.
VNC Server Scripts
Applicable Image: Currently only available for CentOS mirroring.
How to use: Execute the command as root bash install_vnc_server.sh
.
: http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/41181/cn_zh/1504062842088/install_vnc_server.sh
.
Instructions for use
This section takes the CentOS 7.4 64-bit operating system as an example of how to install and run VNC Server automatically in a Linux instance, allowing you to remotely connect to a Linux instance from a Windows system via the VNC viewer.
Pre-conditions
Your instance is in a running state. If the instance does not start, start the instance first.
You have already downloaded and installed the VNC Viewer in your Windows system.
Operation Steps
To do this, follow these steps:
Connect to a Linux instance remotely.
Run the command download script install_vnc_server.sh.
wget http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/41181/cn_zh/1504062842088/install_vnc_server.sh
Run the script as root and install VNC Server.
bash install_vnc_server.sh
Installation takes a long time. When the following information appears on the screen, the VNC server installation is complete. You need to record the random password displayed.
Description : If the script executes an error, you can try several times.
Run the following command to view the ports that the XVNC service is using in the returned results.
netstat -tulnp
In this example, the information for the XVNC process in the returned results is shown below.
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0. 0.0:5901 0.0. 0.0:* LISTEN 1975/xvnc
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 1975/Xvnc
Indicates that the port that VNC server is using is TCP 5901 and 6001, where:
- TCP 5901: Allows VNC clients to connect to VNC Server via the RFB protocol. Select this port when connecting to the instance using the VNC viewer.
- TCP 6001: Allow Windows X to connect to VNC Server.
In the security group where the instance is located, add a security group rule to release the ports required by the XNVC service.
In this example, you need to add 2 security group rules to release TCP 5901 and TCP 6001 ports respectively. The specific rules are shown in the table below.
Network Type |
Network card Type |
Rule Direction |
Authorization Policy |
protocol Type |
Port Range |
Authorization Type |
Authorization Object |
Priority Level |
Vpc |
No Configuration required |
into the direction |
Allow |
Custom TCP |
Set to 5901/5901 and 6001/6001, respectively |
Address segment Access |
0.0.0.0/0 |
1 |
Classic Network |
Public network |
If your instance has a firewall enabled, you need to add a rule release port. To do so, the firewall software installed in your instance will prevail.
In this example, take iptables as an example, you can add rules to release TCP 5901 and port 6001 by executing the following command in turn:
[[email protected] ~]# iptables -A INPUT -p tcp --dport 5901 -j ACCEPT
[[email protected] ~]# iptables -A INPUT -p tcp --dport 6001 -j ACCEPT
[[email protected] ~]# service iptables save
Follow these steps to connect a Linux instance to a local Windows system via the VNC viewer:
- Launch the VNC Viewer in your local Windows system.
- In the toolbar, select File > New Connection.
- In the Properties dialog box, click OKafter configuring the following information:
- VNC Server: Input
Linux 实例的公网 IP 地址:5901
.
- Name: Enter a connection name according to your needs to facilitate later management.
- In the VNC Viewer main window, right-click the icon for the new connection and select Connectfrom the pop-up menu.
In the Authentication dialog box that pops up, enter the random password that appears after the VNC server installation is complete and click OK.
Note :
The password used here is not the login password for the instance.
At this point, you have successfully logged into the Linux instance.
FAQs The first time you log in to a CentOS 6 instance, I am prompted to log in as root Super User (as shown), what should I do?
This is a normal hint. You can do this by following these steps:
- Tick Don't show me this again.
- Close The dialog box by clicking Close.
Automatically install and run VNC Server on a Linux instance