I have a Debian server without monitor, and I wan to access it remotely from my MacOS.
Following is the steps to archive this.
Install and start Virtual Desktop
# Install updates
sudo apt update
# install the Xfce desktop
sudo apt install xfce4 xfce4-goodies
Edit file ~/.vnc/xstartup
and set content to following:
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
Install and start VNC Server
# install the TightVNC server
sudo apt install tightvncserver
# install the dbus-x11 dependency to ensure a proper connection to your VNC server:
sudo apt install dbus-x11
# start vncserver
vncserver
Connect Debian from local MacOS
Open terminal and run ssh tunel:
# turn on the tunnel,
# format: ssh -L [LOCAL_PORT]:[REMOTE_HOST]:[REMOTE_PORT] user@ssh-server
ssh -L 5901:localhost:5901 gary@110.110.110.110
# MacOS open screen sharing and type:
localhost:5901
Restart VNC server
vncserver -kill :1
vncserver :1
Set vnc server auto running at startup
Check who you are:
whoami
Edit file
sudo vim /etc/systemd/system/vncserver@.service
content:
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=gary
Group=gary
WorkingDirectory=/home/gary
PIDFile=/home/gary/.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
and then
sudo systemctl daemon-reload
sudo systemctl enable vncserver@1.service
vncserver -kill :1
sudo systemctl start vncserver@1
sudo systemctl status vncserver@1