Question: How to remotely access graphical environment on an CentOS/RHEL 8?
The access will be used using a VNC server.
Setup VNC Server
1. Install VNC Server and the graphical environment in the server:
$ sudo dnf install tigervnc-server $ sudo dnf group install "Server with GUI"
2. Configure the users that will user VNC. Edit /etc/tigervnc/vncserver.users and add display number and user:
:[display_number]=[user]
For example:
:1=opc
3. Configure the VNC password for [user] and define the default desktop:
$ vncpasswd $ echo session=gnome >> .vnc/config
4. Start the corresponding service:
$ sudo systemctl start vncserver@:[display_number]
For example:
$ sudo systemctl start vncserver@:1
VNC viewer access
To connect to the VNC service it’s recommended to use a SSH tunnel.
Connect using ssh
1. ssh command to connect:
$ ssh [user]@[server] -L 590[display_number]:localhost:590[display_number]
For example:
$ ssh opc@[server] -L 5901:localhost:5901
2. Connect vncviewer:
$ vncviewer localhost:[display_number]
For example:
$ vncviewer localhost:1
Note: To use the tunnel, connect to “localhost”, not the external IP address.
Connect using putty
1. Launch putty:
2. Go to Connection -> SSH -> Tunnels:
3. Click “Add” and then “Open”:
4. Connect VNC Viewer to “localhost:1”: