VNC: Difference between revisions

From DWAMconsult Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Category:Linux]]
[[Category:Linux]]
* Remote access of GUI in Linux (system you are remotely accessing must have GUI installed ...)
== VNC remote desktop viewer ==
* Instructions for RHEL / CentOS 7.4 and newer
 
* Install required packages: <code>yum -y install tigervnc-server tigervnc</code>
=== Instructions for RHEL etc ===
 
* .
 
=== Instructions for Ubuntu/Debian ===
 
* Install VNC server on the system that you want to access <code>yum -y install tigervnc-server tigervnc</code>
*
* Be logged in as the user on the remote system then create a VNC password: <code>vncpasswd</code>
* Be logged in as the user on the remote system then create a VNC password: <code>vncpasswd</code>
** Can have multiple VNC sessions for different users
** Can have multiple VNC sessions for different users

Revision as of 19:34, 28 April 2024

VNC remote desktop viewer

Instructions for RHEL etc

  • .

Instructions for Ubuntu/Debian

  • Install VNC server on the system that you want to access yum -y install tigervnc-server tigervnc
  • Be logged in as the user on the remote system then create a VNC password: vncpasswd
    • Can have multiple VNC sessions for different users
  • As root, created systemd unit file for the user (create a different one for each remote user, changing 1 (which is for the first remote user) to 2, 3, etc)
    • cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
    • Edit this file and replace <USER> with the user name
  • Enable firewall: firewall-cmd --permanent --zone=public --add-port 5901/tcp and firewall-cmd --reload
  • Enable and start the VNC service: systemctl enable vncserver@:1.service and systemctl start vncserver@:1.service remembering you need to do this for each vncserver unit file where you have multiple remote users
  • From client connect to the server using <servername or IP>:1 for the first user, :2 for second user etc
  • More details: https://access.redhat.com/solutions/966063

Better instructions

apt install xfce4 xfce4-goodies
(only for server without GUI)



sudo apt install tightvncserver
sudo apt install dbus-x11
vncserver
set password
set read-only password (useful for sharing session)
vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
vim ~/.vnc/xstartup

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

(for XFCE4.  for gnome, startx?  what about ... Wayland?)

sudo chmod +x ~/.vnc/xstartup
vncserver

connect securely like this:
ssh -L 5901:127.0.0.1:5901 -C -N -l david@your_server_ip


once the secure tunnel is set up use vnc client to connect to localhost:5901

vim /etc/systemd/system/[email protected]

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=sammy
Group=sammy
WorkingDirectory=/home/sammy

PIDFile=/home/sammy/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload
sudo systemctl enable [email protected]
vncserver -kill :1
sudo systemctl start vncserver@1
sudo systemctl status vncserver@1

ssh -L 5901:127.0.0.1:5901 -C -N -l sammy your_server_ip


https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-debian-11