1

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

  • Theoretical you can login via SSH, kill current Xsession, export local display and start new Xsession with startx or similarly. – BlueManCZ Mar 8 '17 at 22:13
  • Have you considered xdotool? I use xdotool type "password" && xdotool key --clearmodifiers "Return" to wake my computer from across the room. – brndn2k Mar 9 '17 at 5:20
  • @brndn2k If you make this an answer I will accept it! But xdotool key --clearmodifiers "Return" doesn't work. I used xdotool key KP_Enter, which works perfectly – Apatus Mar 9 '17 at 9:37
0

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

  • It is a cool solution, but it works only on X server-based displays, like lock screen. It does't work on the lightdm, which internally doesn't use the X server. – Adam Ryczkowski Mar 29 '18 at 5:53
  • 2
    @AdamRyczkowski LightDM does run an X server (that's why your answer works). GDM, for example, can run Wayland instead of X, and neither answer will work in that case. The problem is of accessing the X server with the right privileges. – muru Mar 29 '18 at 9:25
3

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
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.