TigerVNC
TigerVNC
(Tiger Virtual Network Computing) es un sistema de escritorio gráfico compartido que le permite controlar remotamente otros ordenadores.
TigerVNC
trabaja sobre la red cliente-servidor: un servidor comparte su salida (vncserver
) y un cliente (vncviewer
) se conecta al servidor.
De forma diferente a Fedora 15 y Red Hat Enterprise Linux 6, |
Servidor VNC
vncserver
es una utilidad que arranca un escritorio VNC (Computación en Red Virtual). Ejecuta Xvnc con las opciones apropiadas e inicia un administrador de ventanas sobre el escritorio VNC. vncserver
permite a los usuarios ejecutar sesiones separadas en paralelo sobre una máquina a la que pueden acceder cualquier número de clientes desde cualquier lugar.
Instalando el Servidor VNC
Para instalar el servidor TigerVNC, envíe el siguiente comando como root
:
# dnf install tigervnc-server
Configurando el Servidor VNC
-
Se requiere un fichero de configuración llamado
/etc/systemd/system/vncserver@.service
. Para crear este fichero copie el fichero/lib/systemd/system/vncserver@.service
comoroot
:~]#
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@.service
No es necesario incluir el número de pantalla en el nombre del fichero porque
systemd
crea automáticamente la instancia con el nombre apropiado en la memoria a pedido, reemplazando'%i'
en el fichero de servicio por el número de pantalla. Para un único usuario no es necesario renombrar el fichero. Para múltiples usuarios, se requiere un fichero de servicio con un nombre exclusivo para cada usuario, por ejemplo, añadiendo el nombre de usuario al nombre del fichero de alguna manera. Vea detalles en Configurando el Servidor VNC para Dos Usuarios. -
Edite
/etc/systemd/system/vncserver@.service
, reemplazando USER con el nombre del usuario actual. Deje las restantes líneas del fichero sin modificar. El argumento-geometry
especifica el tamaño del escritorio VNC a crear; por defecto está fijado a1024x768
.ExecStart=/sbin/runuser -l USER -c "/usr/bin/vncserver %i -geometry 1280x1024" PIDFile=/home/USER/.vnc/%H%i.pid
-
Guarde los cambios.
-
Para hacer que los cambios surtan efecto inmediatamente, envíe el siguiente comando:
#
systemctl daemon-reload
-
Establezca la contraseña para el usuario o usuarios definidos en el fichero de configuración. Advierta que necesita cambiar de
root
a USER primero.# su - USER $
vncpasswd
Password: Verify:La contraseña almacenada no está encriptada; cualquiera que tenga acceso al fichero password puede encontrar la contraseña en texto plano.
Continúe a Arrancando el Servidor VNC.
Configuring VNC Server for Two Users
Si desea configurar mas de un usuario en la misma máquina, cree diferentes ficheros de servicio de tipo plantilla, uno por cada usuario.
-
Crear dos ficheros de servicio, por ejemplo
vncserver-USER_1@.service
yvncserver-USER_2@.service
. En ambos ficheros sustituya USER por el nombre de usuario correcto. -
Establezca las contraseñas de ambos usuarios:
$ su - USER_1 $ vncpasswd Password: Verify: $ su - USER_2 $ vncpasswd Password: Verify:
Arrancando el Servidor VNC
Para arrancar o habilitar el servicio, especifique el número de pantalla directamente en el comando. El fichero configurado arriba en Configurando la primera conexión VNC trabaja como plantilla, en el que %i
es sustituido por el número de pantalla por systemd
. Con un número de pantalla válido ejecute el siguiente comando:
# systemctl start vncserver@:display_number.service
También puede habilitar que el servicio se inicie automáticamente al arranque del sistema. Entonces, cuando usted accede, vncserver
es arrancado automáticamente. Como root
, envíe un comando como el que sigue:
# systemctl enable vncserver@:display_number.service
En este punto, otros usuarios son capaces de usar un programa visualizador VNC para conectar con el servidor VNC usando el nñumero de pantalla y una contraseña definida. Siempre que haya instalado un escritorio gráfico, se mostrará una instancia de ese escritorio. No será la misma instancia que se mestra actualmente en la maquina destino.
Configuring VNC Server for Two Users and Two Different Displays
Para los dos servidor VNC configurados, vncserver-USER_1@.service y vncserver-USER_2@.service, usted puede habiitar números diferentes de pantallas. Por ejemplo, los siguientes comandos causaran un servidor VNC para que USER_1 arranque en la pantalla 3 y un servidor VNC para que USER_2 arranque en la pantalla 5:
# systemctl start vncserver-USER_1@:3.service # systemctl start vncserver-USER_2@:5.service
Finalizando una Sesión VNC
Similarmente para habilitar el servicio vncserver
, usted puede deshabilitar el inicio automático del servicio en el arranque del sistema:
# systemctl enable vncserver@:display_number.service
O, cuando su sistema está corriendo, puede para el servicio enviando el siguiente comando como root
:
# systemctl start vncserver@:display_number.service
Visor VNC
vncviewer
es el programa que muestra las interfaces gráficas de usuario compartidas y controla el servidor.
Para trabajar con el vncviewer
hay un menú desplegable que contiene entradas que llevan a cabo diversas acciones como entrar o salir del modo de pantalla completa o abandonar el visor. Alternativamente, usted puede trabajar con vncviewer
a través del terminal. Introduzca vncviewer -h en la línea de comando para listar los parámetros de vncviewer
.
Instalando el Visor VNC
Para instalar el cliente TigerVNC, vncviewer>, envíe el siguiente comando como root
:
# dnf install tigervnc
Connecting to VNC Server
Once the VNC server is configured, you can connect to it from any VNC viewer. In order to do so, issue the vncviewer command in the following format:
vncviewer address:port_number
Where address is an IP
or host name.
With the IP
address 192.168.0.4
and display number 3 the command looks as follows:
$ vncviewer 192.168.0.4:3
Configuring the Firewall for VNC
When using a non-encrypted connection, firewalld
might block the connection. To allow firewalld
to pass the VNC packets, you can open specific ports to TCP
traffic. When using the -via
option, traffic is redirected over SSH
which is enabled by default in firewalld
.
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 port: 2 + 5900 = 5902. |
For displays 0
to 3
, make use of firewalld
's support for the VNC service by means of the service
option as described below. Note that for display numbers greater than 3
, the corresponding ports will have to be opened specifically as explained in Opening Ports in firewalld.
-
Run the following command to see the information concerning
firewalld
settings:$ firewall-cmd --list-all
-
To allow all VNC connections from a specific address, use a command as follows:
# firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.122.116" service name=vnc-server accept' success
See the Red Hat Enterprise Linux 7 Security Guide for more information on the use of firewall rich language commands.
-
To verify the above settings, use a command as follows:
# firewall-cmd --list-all public (default, active) interfaces: bond0 bond0.192 sources: services: dhcpv6-client ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules: rule family="ipv4" source address="192.168.122.116" service name="vnc-server" accept
To open a specific port or range of ports make use of the --add-port
option to the firewall-cmd command Line tool. For example, VNC display 4
requires port 5904
to be opened for TCP
traffic.
-
To open a port for
TCP
traffic in the public zone, issue a command asroot
as follows:# firewall-cmd --zone=public --add-port=5904/tcp success
-
To view the ports that are currently open for the public zone, issue a command as follows:
# firewall-cmd --zone=public --list-ports 5904/tcp
A port can be removed using the firewall-cmd --zone=zone --remove-port=number/protocol command.
For more information on opening and closing ports in firewalld
, see the Red Hat Enterprise Linux 7 Security Guide.
Connecting to VNC Server Using SSH
VNC is a clear text network protocol with no security against possible attacks on the communication. To make the communication secure, you can encrypt your server-client connection by using the -via
option. This will create an SSH
tunnel between the VNC server and the client.
The format of the command to encrypt a VNC server-client connection is as follows:
$ vncviewer -via user@host:display_number
-
To connect to a VNC server using
SSH
, enter a command as follows:$ vncviewer -via USER_2@192.168.2.101:3
-
When you are prompted to, type the password, and confirm by pressing Enter.
-
A window with a remote desktop appears on your screen.
If you prefer only encrypted connections, you can prevent unencrypted connections altogether by using the -localhost
option in the systemd.service
file, the ExecStart line:
ExecStart=/sbin/runuser -l user -c "/usr/bin/vncserver -localhost %i"
This will stop vncserver
from accepting connections from anything but the local host and port-forwarded connections sent using SSH
as a result of the -via
option.
For more information on using SSH
, see OpenSSH.
Want to help? Learn how to contribute to Fedora Docs ›