Enable Gnome Screen Sharing via Commandline?

I set up a automated kickstart-installation based on Fedora 30 (soon 32), now I want to add the enabling of the “Gnome Screen Sharing” to the installation. I got this to work via the settings in the GUI (Settings - Sharing - Screen Sharing) and I’m also able to set the “subsettings” via gesettings, e.g.

gsettings set org.gnome.desktop.remote-desktop.vnc view-only false
gsettings set org.gnome.desktop.remote-desktop.vnc auth-method 'password'

But I wasn’t able to find the setting to enable the “Screen Sharing” itself. When I enable it via the GUI, I can see via systemctl status :

systemctl status | grep gnome-remote | grep -v grep
           │   │ ├─gnome-remote-desktop.service
           │   │ │ └─5572 /usr/libexec/gnome-remote-desktop-daemon

I tried to start this service and also the “daemon” directly with systemctl start, but it only results in Failed to start gnome-remote-desktop-daemon.service: Unit gnome-remote-desktop-daemon.service not found.

There are two quite similar questions on stackexchange, but the seem outdated, because I don’t have a schema “org.gnome.Vino”.

Also i don’t have a vino-server systemctl service, which i could start, like described in a topic here. Has someone an idea how I can start the remote-desktop service?

Thanks in advance,
Markus

1 Like

I’ve invested a lot of time to get this to work and could solve all but one problem. I now know, that I have to start the service as User, so my whole procedure is:

gsettings set org.gnome.desktop.remote-desktop.vnc auth-method 'password'
gsettings set org.gnome.desktop.remote-desktop.vnc view-only false
gsettings set org.gnome.settings-daemon.plugins.sharing.service:/org/gnome/settings-daemon/plugins/sharing/gnome-remote-desktop/ enabled-connections "['$( grep UUID /etc/sysconfig/network-scripts/ifcfg-enp1s0 | cut -d= -f2)']"

# Start the Remote-Desktop-Service
systemctl start --user gnome-remote-desktop

I set it to “password” to not have someone to click on “accept”, “view-only” to “false” to be able to control it and set the UUID of my network-interface. Afterwards I can start the service correctly configured. The last missing step is, that I’m not able to set the password via the commandline. I tried it like for vino and also with secret-tool, but it doesn’t work

gsettings set org.gnome.Vino vnc-password $(echo -n "myPassword"|base64)
secret-tool store (...)

So because in my case I only need a way to check whats on the screen right now, the new approach is, to make a screenshot. But even this is difficult, i guess because of wayland. I tried to start “gnome-screenshot” via cronjob - of course this dosen’t work, although it works when i do this directly in the terminal.
Has someone an idea, how I can take a Screenshot via commandline-SSH-Connection?

Thanks,
Markus

3 Likes

Thanks to a guy on stackexchange, I’m now able to get screenshots over SSH. One simply has to set WAYLAND_DISPLAY and gnome-screenshots works:

WAYLAND_DISPLAY=wayland-0
gnome-screenshot

I guess there has to be a Display connected to the client (but I haven’t tested it without) and the screenshots are stored in the Homedirectory of the user under Pictures. An also under wayland working alternative to gnome-screenshot would be “flameshot”, available in the official repositories.
This isn’t a solution for the original question, but a solution for my case. Maybe this helps someone!

Regards,
Markus

4 Likes

Markus thanks for posting this, it helped a lot
I’m running Ubuntu 21.04 though but your tips were invaluable
I have managed to set password with (shall work in Fedora too):

echo -n 'keyringpass' | gnome-keyring-daemon --unlock 
echo -n 'vncpassword' | secret-tool store --label="GNOME Remote Desktop VNC password" "xdg:schema" "org.gnome.RemoteDesktop.VncPassword"

on my ubuntu installation keyringpass was same as user password

But you are right, you need connected display, gnome remote desktop is not yet ready for headless sessions, without monitor:

I’ve got GDBus.Error:org.freedesktop.DBus.Error.Failed: Unknown Monitor like in this issue #49

If getting ‘secret-tool: Cannot create an item in a locked collection’ error try dbus-run-session like suggested here: keyring/README.rst at main · jaraco/keyring · GitHub

1 Like

Can you share more about screen shot over ssh?

You have to SSH directly to the user that has the gnome-session on the monitor, set WAYLAND_DISPLAY like described and you can take the screenshot with gnome-screenshot and it is stored under Pictures, eg. ~/Pictures/Screenshot from 2021-04-28 07-03-50.png. And that’s it.

ssh logged_in_user@client
WAYLAND_DISPLAY=wayland-0
gnome-screenshot

I did not manage to do it by SSH to another user and sudo su - logged_in_user to, because it can not connect to the display then.
In my case I take the screenshots with a cronjob and convert them to a smaller size.

@zuragvi Thanks for the post, I will try this.

2 Likes

Thank you very much for sharing :smiling_face: