15.3.2. Connecting to a VNC Server
Once the VNC server is configured, you can connect to it from any VNC viewer.
Procedure 15.6. Connecting to a VNC Server Using a GUI
- Enter the
vncviewer
command with no arguments, the VNC Viewer: Connection Details utility appears. It prompts for a VNC server to connect to. - If required, to prevent disconnecting any existing VNC connections to the same display, select the option to allow sharing of the desktop as follows:
- Select thebutton.
- Select the Misc. tab.
- Select thebutton.
- Press OK to return to the main menu.
- Enter an address and display number to connect to:
address:display_number
address:display_number
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Press Connect to connect to the VNC server display.
- You will be prompted to enter the VNC password. This will be the VNC password for the user corresponding to the display number unless a global default VNC password was set.A window appears showing the VNC server desktop. Note that this is not the desktop the normal user sees, it is an Xvnc desktop.
Procedure 15.7. Connecting to a VNC Server Using the CLI
- Enter the
viewer
command with the address and display number as arguments:Where address is anvncviewer address:display_number
vncviewer address:display_number
Copy to Clipboard Copied! Toggle word wrap Toggle overflow IP
address or host name. - Authenticate yourself by entering the VNC password. This will be the VNC password for the user corresponding to the display number unless a global default VNC password was set.
- A window appears showing the VNC server desktop. Note that this is not the desktop the normal user sees, it is the Xvnc desktop.
15.3.2.1. Configuring the Firewall for VNC Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
When using a non-encrypted connection, the firewall might block your connection. The VNC protocol is remote framebuffer (RFB), which is transported in
TCP
packets. If required, open a port for the TCP
protocol as described below. When using the -via
option, traffic is redirected over SSH
which is enabled by default.
Note
The default port of VNC server is 5900. To reach the port through which a remote desktop will be accessible, sum the default port and the user's assigned display number. For example, for the second display: 2 + 5900 = 5902.
Procedure 15.8. Opening a Port Using lokkit
The
lokkit
command provides a way to quickly enable a port using the command line.
- To enable a specific port, for example port
5902
forTCP
, issue the following command asroot
:Note that this will restart the firewall as long as it has not been disabled with thelokkit --port=5902:tcp --update
~]# lokkit --port=5902:tcp --update
Copy to Clipboard Copied! Toggle word wrap Toggle overflow --disabled
option. Active connections will be terminated and time out on the initiating machine. - Verify whether the chosen port is open. As
root
, enter:iptables -L -n | grep 'tcp.*59'
~]# iptables -L -n | grep 'tcp.*59' ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:5902
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - If you are unsure of the port numbers in use for VNC, as
root
, enter:Ports startingCopy to Clipboard Copied! Toggle word wrap Toggle overflow 59XX
are for the VNCRFB
protocol. Ports starting60XX
are for the X windows protocol.To list the ports and the Xvnc session's associated user, asroot
, enter:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 15.9. Configuring the Firewall Using an Editor
When preparing a configuration file for multiple installations using administration tools, it is useful to edit the firewall configuration file directly. Note that any mistakes in the configuration file could have unexpected consequences, cause an error, and prevent the firewall settings from being applied. Therefore, check the
/etc/sysconfig/system-config-firewall
file thoroughly after editing.
- To check what the firewall is configured to allow, issue the following command as
root
to view the firewall configuration file:In this example taken from a default installation, the firewall is enabled but VNC ports have not been configured to pass through.less /etc/sysconfig/system-config-firewall
~]# less /etc/sysconfig/system-config-firewall # Configuration file for system-config-firewall --enabled --service=ssh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Open
/etc/sysconfig/system-config-firewall
for editing asroot
and add lines in the following format to the firewall configuration file:For example, to add port--port=port_number:tcp
--port=port_number:tcp
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 5902
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Note that these changes will not take effect even if the firewall is reloaded or the system rebooted. To apply the settings in
/etc/sysconfig/system-config-firewall
, issue the following command asroot
:lokkit --update
~]# lokkit --update
Copy to Clipboard Copied! Toggle word wrap Toggle overflow