How to Setup VNC Server (Linux Remote Desktop Access) on CentOS/RHEL 7 and Fedora
See also:
How to Install xrdp on CentOS 7 / RHEL 7
Install vnc package:
sudo dnf -y install tigervnc-server
Add user: ( or just use existing linux user)
sudo useradd
Set VNC password for that user
vncpasswd
sudo cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service
(1 is the display number, you can setup 2, 3 ...)
sudo cat /lib/systemd/system/vncserver@\:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
Make sure your firewall allows to connect to port 590D
sudo -i firewall-cmd --list-ports | grep 590
sudo firewall-cmd --add-port=5901/tcp --permanent
sudo firewall-cmd --reload
See also: How to configure firewall on CentOS /Oracle Linux/ Red Hat 7
Connect from the client:
To access from remote Linux system use following command.
How to Install xrdp on CentOS 7 / RHEL 7
Install vnc package:
sudo dnf -y install tigervnc-server
sudo useradd
Set VNC password for that user
vncpasswd
sudo cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service
(1 is the display number, you can setup 2, 3 ...)
sudo cat /lib/systemd/system/vncserver@\:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable vncserver@:1.service
sudo systemctl start vncserver@:1.service
Check the server is listening on the port: 590D (D is the display number corresponding to the one you set up )
$ sudo ss -na | grep 590
u_seq LISTEN 0 128 /run/udev/control 15907 * 0
tcp LISTEN 0 5 *:5900 *:*
tcp LISTEN 0 5 :::5900 :::*
tcp LISTEN 0 5 *:5900 *:*
tcp LISTEN 0 5 :::5900 :::*
sudo -i firewall-cmd --list-ports | grep 590
sudo firewall-cmd --add-port=5901/tcp --permanent
sudo firewall-cmd --reload
See also: How to configure firewall on CentOS /Oracle Linux/ Red Hat 7
Connect from the client:
To access from remote Linux system use following command.
$ vncviewer 192.168.2.198:1
$ gvncviewer 192.168.1.199:1
$ jvncviewer 192.168.1.199:1
To access remote desktop on vnc-server from windows system, you must have vnc-viewer installed on your system. There are various vnc viewer available to use. Download any one and install on your system, for example:
$ gvncviewer 192.168.1.199:1
$ jvncviewer 192.168.1.199:1
To access remote desktop on vnc-server from windows system, you must have vnc-viewer installed on your system. There are various vnc viewer available to use. Download any one and install on your system, for example:
- TigerVNC: http://sourceforge.net/projects/tigervnc/files/tigervnc/
- TightVNC: http://www.tightvnc.com/download.php
- RealVNC: https://www.realvnc.com/download/vnc/
You may want to use SSL tunnel to connect to remote VNC server. See also
SSH Port Forwarding (tunnel) in Linux
SSH Port Forwarding (tunnel) in Linux
Comments
Post a Comment