From https://unix.stackexchange.com/a/505644/674
When you're using SSH, you can access the screen you're connected from by using ssh -X or ssh -Y . Programs can perfectly run on a machine and display on another one. So if you run light-locker through SSH on the remote machine, it will lock your local display and not the remote one (just as running gnome-terminal or any other command will run it on the remote machine but display it locally).
if you want the screen to lock again, yes, you'll have to restart it, but be careful to restart it from the X session you want to lock, not from ssh.
I ssh to a machine, and then want to lock its screen. Could anyone tell me why I failed and what I shall do? Thanks.
$ xscreensaver-command -lock
xscreensaver-command: warning: $DISPLAY is not set: defaulting to ":0.0".
xscreensaver-command: no screensaver is running on display :0.0
$ DISPLAY=:0 xscreensaver-command -lock
xscreensaver-command: no screensaver is running on display :0
Not sure how one can tell there is no X server running on the remote host:
$ ps -A | grep -i xorg
448 ? 00:00:29 Xorg
605 ? 00:00:27 Xorg
766 tty7 05:19:26 Xorg
2175 ? 00:02:58 Xorg
3343 ? 00:00:24 Xorg
8520 ? 00:00:28 Xorg
12564 ? 00:00:22 Xorg
24655 ? 00:00:13 Xorg
26692 ? 00:00:28 Xorg
26704 ? 00:00:25 Xorg
26852 ? 00:00:29 Xorg
27034 ? 00:00:23 Xorg
ssh
(from another computer) with and without prefixDISPLAY=:0
as in your question. It works in both cases. – sudodus Mar 15 '19 at 17:26gnome-screensaver
installed. What command doesdbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
invoke? (2) How can you unlock the remote desktop? – Tim Mar 15 '19 at 17:53