Question: I installed elementary OS on my laptop and tried to install VNC server. First I installed `vnc4server`, opened and logged from phone. On screen I saw:

```
failed to load session gnome

```

How do I need to configure it to run under elementary OS? I am not interested in installing GNOME.

Answer: 
Create a file named .xsession in your home directory and write the following content into it.

```
 gnome-session --session=pantheon

```

Then restart the vncserver and connect again. I tested this with tightvncserver.

---

If you want to use display:0 use x11vnc. [Here you can find more information](https://raspberrypi.stackexchange.com/questions/9590/tightvncserver-show-the-same-screen-on-hdmi-and-vncclient) about how to setup and connect to a x11vnc server.
1. Install *X11VNC Server* from AppCenter.
2. Run:

```bsh
sudo x11vnc -storepasswd # This will prompt password and the confirmation of it.

```

3. Create the file `/etc/systemd/system/x11vnc.service` with the following commands:

```bsh
echo "[Unit]" | sudo tee /etc/systemd/system/x11vnc.service
echo "Description=\"x11vnc\"" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "Requires=display-manager.service" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "After=display-manager.service" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "[Service]" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /home/$(whoami)/.vnc/passwd" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "ExecStop=/usr/bin/killall x11vnc" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "Restart=on-failure" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "RestartSec=2" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "[Install]" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/x11vnc.service
echo "" | sudo tee -a /etc/systemd/system/x11vnc.service

```

4. Make the system get the changes:

```bsh
sudo systemctl daemon-reload
sudo systemctl start x11vnc.service
sudo systemctl enable x11vnc.service

```

Done. This should allow you to hook into existing session or start a new one.

Tested with:

```bsh
$ lsb_release -a
No LSB modules are available.
Distributor ID: elementary
Description:    elementary OS 5.1.7 Hera
Release:    5.1.7
Codename:   hera

```

[Source](https://askubuntu.com/questions/229989/how-to-setup-x11vnc-to-access-with-graphical-login-screen)