$ ssh -X user@server “export DISPLAY=:0; gnome-screensaver; gnome-screensaver-command -l;”
You may use that command without “-X” option if you have X forwarding enabled (ForwardX11 yes) on your ssh configuration. But you need to remember with “export DISPLAY=:0”, without this the command will give the lock screen on your computer, not your remote computer.
To unlock the screen on your remote computer, type this command on your computer :
$ ssh -X user@server “export DISPLAY=:0; gnome-screensaver; gnome-screensaver-command -d;”
sumber : http://z-computer-z.blogspot.com/2010/01/remote-lock-screen-and-remote-unlock.html