If I start my Computer remotely and I want someone to access it with my account without saying them my password, I have to get VNC started and login.

Is there a way to manage that over ssh? So that I can login an account over the terminal?

I hope you can help me


Solution 1:

Here is an answer, that works under Ubuntu 16.04 with lightdm:

  1. Make yourself root to get access to the lightdm's .Xauthority, which is located under /var/lib/lightdm/.Xauthority. Either copy it somewhere where it will be readable by you and drop your root permissions, or simply remain root.
  2. set XAUTHORITY to point to that file (e.g. export XAUTHORITY=/var/lib/lightdm/.Xauthority)
  3. set DISPLAY to the active display (export DISPLAY=:0)
  4. xdotool should work now. Try

    xdotool type "My super secret password"
    xdotool key Return
    

Solution 2:

You can simulate typing by using xdotool

xdotool type "password" && xdotool key --clearmodifiers "Return"

should type your password and then type the return key to submit the password