5

First of all: I googled all day and tried several suggestions on different forums with no luck

The problem: I am not able to start a vnc server on a remote machine through ssh Additional information:

  • Host: Ubuntu 12.04
  • client: Ubuntu 14.04 in VritualBox
  • I have no physical access to the remote machine

this works:

ssh -Y user@hostname

When I check the Display i get this:

$ echo $DISPLAY
localhost:10.0

now I start the vnc server: /usr/lib/vino/vino-server

=> this works but when I connect to vnc I see my own screen (from the ssh client) and not the remote screen

It looks like localhost:10.0 takes my local screen. Am I right?

I also tried this as I want the remote screen:

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

which results in the following:

$ /usr/lib/vino/vino-server --display 0.0

(process:6843): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.
Cannot open display: 0.0
Run 'vino-server --help' to see a full list of available command line options

Why is it not able to open display 0.0?

5
  • How exactly are you "connect[ing] to vnc"? Feb 26, 2015 at 15:00
  • @steeldriver through a vnc client on a Windows machine (RealVNC)
    – Charlie
    Feb 26, 2015 at 15:04
  • OK but what host and port (or display) information are you entering for the target vino-server? Feb 26, 2015 at 15:06
  • host is the same host as the ssh. So just the IP. And no specific port
    – Charlie
    Feb 26, 2015 at 15:45
  • A DevOps helped me out. Apparently LightDM was not running. Now I can connect with the VNC server!
    – Charlie
    Feb 26, 2015 at 15:47

2 Answers 2

3

In another forum, forum.developer.nvidia.com, "nekokeitai" wrote something which worked for me. These commands can be used via ssh on the remote Ubuntu 18.04 PC:

Install vino:

sudo apt install vino

Find the UUIDs of your connections and use them as a comma separated list inside the square brackets of the last configuration line. I have only tried one UUID inside the single quotes, though:

nmcli connection show

Configure vino:

gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino require-encryption false
dconf write /org/gnome/settings-daemon/plugins/sharing/vino-server/enabled-connections "['']"

Start vino:

export DISPLAY=:0 && /usr/lib/vino/vino-server

Now, on the local PC use remmina with VNC protocol to connect to the remote PC.

0

Here is some scripts I use to install vino onto remotes.

Within a main setup script I will just include the code that calls the vnc_access script (which is in a subdirectory 'vnc' but change this to wherever you put the 2nd script.

if [ ! -z "$install_vnc" ] ; then
    user_password='password'
    vnc_password='password'
    vnc_script="${BASH_SOURCE%/*}/vnc/vnc_access.sh"

    printf '\n\tSetting up vino-server on host...\n' >&2

    ssh $host_user_name@$host_address \
        "bash -s" < "$vnc_script" $user_password "'$vnc_password'"

    printf '\n\tDone sending vnc to host.\n' >&2
fi

And here is the vnc_access.sh script

#!/bin/bash
#
# Tools to enable and configure vino for vnc access

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# parse arguments
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
user_password=$1
vino_password=$2

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# initialize values
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vino_password_binary="$(echo -n ${vino_password} | base64)"

declare -A settings
settings[alternative-port]="uint16 5900"
settings[authentication-methods]="['vnc']"
settings[disable-background]=false
settings[disable-xdamage]=false
settings[enabled]=true
# enum 'never' 'always' 'client'
settings[icon-visibility]="'client'"
settings[lock-screen-on-disconnect]=false
settings[mailto]="''"
settings[network-interface]="''"
settings[notify-on-connect]=true
settings[prompt-enabled]=false
settings[require-encryption]=false
settings[use-alternative-port]=false
settings[use-upnp]=false
settings[view-only]=false
settings[vnc-password]="'$vino_password_binary'"

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# main
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# We need to have sudo enabled to do many of these tasks, 
#  this is a bit of a hack, but it gets the job done.
printf "Enabling sudo privileges...\n" >&2
echo $user_password | sudo -S whoami >/dev/null
printf "\n" >&2

# If vino is not installed, install it
if [ -z "$(dpkg -l | egrep -i 'vino')" ] ; then
    printf "Installing vino...\n" >&2
    sudo apt-get update
    sudo apt-get install -y vino
fi

# Make sure we are performing these operations of the remotes display.
printf "Forwarding X org Display...\n" >&2
export DISPLAY=:0
sudo xhost +

# Loop through settings and configure vino.
for setting in "${!settings[@]}" ; do
    current_value="$(gsettings get org.gnome.Vino "$setting")"
    to_value="${settings[$setting]}"
    if [[ "$current_value" != "$to_value" ]] ; then
        printf "changing Vino's ${setting} from ${current_value} to ${settings[$setting]}\n" >&2
        DISPLAY=:0 sudo gsettings set org.gnome.Vino "$setting" ${settings[$setting]}
    fi
done

# Vino requires a reboot to work. If someone can find out how to do this with
#  out rebooting or logging out, let me know.
sudo reboot
1
  • It seems that running these scripts would reboot the computer. Is that correct? If so, it is worth mentioning explicitly. Feb 28, 2020 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .