Enable Remote Desktop in Ubuntu from the command line
Method 1: Using x11vnc
Connect to remote computer with SSH
1 |
ssh user@REMOTE_PC_IP |
Install x11vnc
1 |
sudo apt install x11vnc |
start x11vnc as the user that is logged in to GUI.
1 |
x11vnc -display :0 |
Now you should be able to connect to the desktop using any vnc client software using
1 |
REMOTE_PC_IP:0 |
Method 2: Using vino
Connect to remote computer with SSH
1 |
ssh -Y user@REMOTE_PC_IP |
Run
1 2 |
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
1 2 3 |
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.
1 |
/usr/lib/vino/vino-server & |
To verify vino running, run
1 |
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
1 2 3 4 5 6 7 8 9 |
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
1 2 |
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
1 2 3 4 |
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
1 |
/usr/lib/vino/vino-server --display=:0.0 |
To view the settings
1 2 3 |
gsettings list-recursively org.gnome.Vino gsettings list-recursively org.gnome.desktop.notifications dconf dump /org/gnome/ |