Set VNC server in LINUX to configure service clients and servers

Source: Internet
Author: User

It is particularly worth mentioning that VNC server configurations are worth learning. Here we mainly introduce VNC server configurations, including starting VNC server services. The support for a specific computing environment makes every operating system suitable for its own work. This is the system's support for a specific computing environment. Remote desktop settings set VNC server on Fedora.

I have always wanted to write a detailed VNC server configuration process under redhat to help some friends who want to read man pages with the same requirements as me, later, I found someone has written a tutorial on www.fedoranews.org and it is not bad. Simply translate it. You can read the original text directly. Here I just give a rough explanation to help those friends who are unwilling to read letters.

What is VNC?

VNC is short for Virtual Network Computing. it is a remote control program that allows users to use simple programs anywhere on the Internet to interact with a specific computer (server. the two interactive computers do not have to be of the same type, so you can view the Linux machines running in the office on a windows PC at home. VNC can be freely obtained and used by millions of people. They come from different aspects such as industry, academic and personal applications. For more information, please visit http://www.realvnc.com/is this software already available in my system?

Run the following command to check whether the VNC client and server have been installed in your system:
[Tchung @ tchung101 tchung] $ rpm-q VNC-server
VNC-4.0-0.beta4.3.2
VNC-server-4.0-0.beta4.3.2
[Tchung @ tchung101 tchung] $

To configure the VNC server as a system service, add your user name to the following VNC server configuration file:
CODE: [Copy to clipboard] [tchung @ tchung101 tchung] $ sudo vi/etc/sysconfig/VNCservers
# The VNCSERVERS variable is a list of display: user pairs.
#
# Uncomment the line below to start a VNC server on display: 1
# As my 'myusername' (adjust this to your own). You will also
# Need to set a VNC password; run 'man vncpasswd' to see how
# To do that.
#
# Do not run this service if your local area network is
# Untrusted! For a secure way of using VNC, see
# URL: http://www.uk.research.att.com/VNC/sshVNC.html
# VNCSERVERS = "1: myusername"
VNCSERVERS = "1: tchung"

Before starting the VNC service, let's use the VNC passwd command to create a VNC password. Note that this will create a hidden directory under your home directory. VNC. A file named passwd stores your VNC password.
CODE: [Copy to clipboard] [tchung @ tchung101 tchung] $ VNC passwd
Password:
Verify:
[Tchung @ tchung101 tchung] $ ls-d. VNC
. VNC
[Tchung @ tchung101 tchung] $ ls. VNC
Passwd
[Tchung @ tchung101 tchung] $

Start the VNC server service.

CODE: [Copy to clipboard] [tchung @ tchung101 tchung] $ sudo/sbin/service VNC server start
Starting VNC server: 1: tchung [OK]
[Tchung @ tchung101 tchung] $
Check the contents of the. VNC directory. It should be similar to the following.
CODE: [Copy to clipboard] [tchung @ tchung101 tchung] $ cd. VNC
[Tchung @ tchung101. VNC] $ ls
Passwd tchung101: 1.log tchung101: 1.pid xstartup
[Tchung @ tchung101. VNC] $
Edit the script named xstartup and note the notes in the red section below.
Remove the annotator in front of the two lines marked with red content, otherwise you will only get a gray screen with nothing.
#! /Bin/sh
# Uncomment the following two lines for normal desktop:
Unset SESSION_MANAGER
Exec/etc/X11/xinit/xinitrc
[-X/etc/VNC/xstartup] & exec/etc/VNC/xstartup
[-R $ HOME/. Xresources] & xrdb $ HOME/. Xresources
Xsetroot-solid gray
VNCconfig-iconic &
Xterm-geometry 80x24 + 10 + 10-ls-title "$ VNCDESKTOP Desktop "&
Twm &

Because we have modified the startup script, now we can restart the VNC server configuration.

CODE: [Copy to clipboard] [tchung @ tchung101 tchung] $ sudo/sbin/service VNCserver restart
Shutting down VNC server: 1: tchung [OK]
Starting VNC server: 1: tchung [OK]
[Tchung @ tchung101 tchung] $
So how to connect to the VNC server? Use the VNC viewer command of the client as follows.
[Tchung @ tchung101 tchung] $ VNC viewer localhost: 1
Enter your VNC password and check the result.

Update:
When using the firewall to connect to a remote system, port 5901 must be enabled.
Add the following red parts and restart the iptables service.
[Tchung @ tchung101 tchung] $ sudo vi/etc/sysconfig/iptables
# Firewall configuration written by redhat-config-securitylevel
# Manual customization of this file is not recommended.
* Filter
: Input accept [0]
: Forward accept [0]
: Output accept [0]
RH-Firewall-1-INPUT-[0]
-A input-j RH-Firewall-1-INPUT
-A forward-j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT-I lo-j ACCEPT
-A RH-Firewall-1-INPUT-p icmp -- icmp-type any-j ACCEPT
-An RH-Firewall-1-INPUT-p 50-j ACCEPT
-An RH-Firewall-1-INPUT-p 51-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state ESTABLISHED, RELATED-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 5901-j ACCEPT
-A RH-Firewall-1-INPUT-j REJECT -- reject-with icmp-host-prohibited
COMMIT

[Tchung @ tchung101 tchung] $ sudo/sbin/service iptables restart
Flushing firewall rules: [OK]
Setting chains to policy ACCEPT: filter [OK]
Unloading iptables modules: [OK]
Applying iptables firewall rules: [OK]
[Tchung @ tchung101 tchung] $
TIP provided by Forrest Taylor
Let the VNC server Configuration accept two different users:

CODE: [Copy to clipboard] vnc servers = "1: tchung 2: thomasc"
Of course, you need to run VNC passwd for the two users respectively to set the password. in addition, you should understand that the VNC server uses port 5901 to connect to 1. If you want to support two users like above, you should enable both 5901 and 5902.

Remote desktop settings part2: VNC + ssh tunneling using putty

There was a previous article on VNC server configuration settings (http://bbs.chinaunix.net/forum/viewtopic.php? T = 368552 & highlight = yunqing), we can run the VNC server on a Linux server for remote access, but note that, if you directly use VNC viewer for access, there are two disadvantages:
1. Password transmission is in plain text and can be easily listened.
2. the firewall needs to open port 59xx, which is impossible in the normal unit.
Fortunately, we have ssh, a powerful tool, like X11 Forwarding. We can use the ssh tunnel to protect the communication process. The following is a brief introduction.
Assume that the VNC server is configured to run on screen 1 of myserver (IP Address: 192.168.x.x), that is, listen for 192.168.x.x: 5901, and the user name is foo.

Scenario 1: configure the client as Linux

This situation is very simple. ssh suites are installed by default in general Linux releases.

1. log on to the server using ssh
Ssh-L 5901: localhost: 5901-l foo myserver or directly use the IP address
Ssh-L 5901: localhost: 5901-l foo 192.168.x.x

2. Run VNC viewer (or other similar tools) on another terminal on the local machine)
VNC viewer localhost: 1

Scenario 2: The VNC client is windows

1. Download an ssh client, personal recommendations putty, only one program, do not need to install, simple and functional. Download http://www.chiark.greenend.org.uk here /~ Sgtatham/putty/download.html
Download putty.exe and run it directly on the desktop.
2. Run putty, enter the IP address of the server, and enter a name. Here, myserver serves as the session name, and press save to save. See figure 1.
3. Click tunnels on the left of the dialog box to select related settings, enter 5901 in source port, enter localhost: 5901 in Destination, and press Add, as shown in figure 2.
4. Click session on the left side, return to session settings, and press save to save the settings. Click open to log on to the server.
5. run VNC-viewer (if not, download the http://www.real vnc.com/download.html here, just one exefile), enter localhost: 1 in the Server, see Figure 3, after the password is entered, a Linux desktop will appear in windows, and it is very safe. Cool?

For more information, see:
Remote desktop settings part1: VNC server configuration procedure on Fedora (http://bbs.chinaunix.net/forum/viewtopic.php? T = 368552 & highlight = yunqing)

  1. Describes how to remotely control Ubuntu VNC
  2. Learning Manual: Install VNC in SUSE Linux
  3. Remote Linux operating system using VNC
  4. How to Use VNC to connect to a Linux Server
  5. Use SSH to protect your VNC remote connection

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.