Enable Remote Desktop in Ubuntu from the command line

Method 1: Using x11vnc

Connect to remote computer with SSH

ssh user@REMOTE_PC_IP

Install x11vnc

sudo apt install x11vnc

start x11vnc as the user that is logged in to GUI.

x11vnc -display :0

Now you should be able to connect to the desktop using any vnc client software using

REMOTE_PC_IP:0

Method 2: Using vino

Connect to remote computer with SSH

ssh -Y user@REMOTE_PC_IP

Run

sudo apt-get install vino -y
vino-preferences

You need X11 forward enabled to get this working, so you can run GUI application of remote PC on your PC.

Configure settings as required.

Now run

export DISPLAY=:0.0
xhost +
/usr/lib/vino/vino-server

This will start vino-server, if you want to run in background, run with & at end.

/usr/lib/vino/vino-server &

To verify vino running, run

netstat -nl | grep 5900 

Now you have VNC enabled on remote PC.

Start your favorite VNC client and connect to remote PC.

If you don’t have vino-preferences, you can use

export DISPLAY=0.0
gsettings set org.gnome.Vino notify-on-connect false
gsettings set org.gnome.Vino prompt-enabled false
gsettings get org.gnome.desktop.notifications.application:/org/gnome/desktop/notifications/application/vino-server/ enable
gsettings set org.gnome.desktop.notifications.application:/org/gnome/desktop/notifications/application/vino-server/ enable false
gsettings set org.gnome.desktop.notifications show-in-lock-screen false
gsettings set org.gnome.desktop.notifications show-banners false
gsettings set org.gnome.Vino require-encryption false
gsettings set org.gnome.Vino view-only false

To set password for VNC, run

dbus-launch gsettings set org.gnome.Vino authentication-methods "['vnc']"
dbus-launch gsettings set org.gnome.Vino vnc-password $(echo -n "YOUR_VNC_PW_HERE"|base64)

Allow connection from a network interface

eths=$(nmcli -t -f uuid,type c s --active | grep 802 | awk -F  ":" '{ print "'\''" $1 "'\''" }' | paste -s -d, -)
gsettings set org.gnome.settings-daemon.plugins.sharing.service:/org/gnome/settings-daemon/plugins/sharing/vino-server/ enabled-connections "[ $eths ]"
dbus-launch gsettings set org.gnome.settings-daemon.plugins.sharing.service:/org/gnome/settings-daemon/plugins/sharing/vino-server/ enabled-connections "[ $eths ]"
gsettings get org.gnome.settings-daemon.plugins.sharing.service:/org/gnome/settings-daemon/plugins/sharing/vino-server/ enabled-connections

start vino server

/usr/lib/vino/vino-server --display=:0.0

To view the settings

gsettings list-recursively org.gnome.Vino
gsettings list-recursively org.gnome.desktop.notifications
dconf dump /org/gnome/

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *