4

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

3
  • Theoretical you can login via SSH, kill current Xsession, export local display and start new Xsession with startx or similarly.
    – BlueManCZ
    Mar 8, 2017 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, 2017 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, 2017 at 9:37

2 Answers 2

5

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
    
1
  • 1
    In Ubuntu 22.04 and up, Wayland is the default, so it will not accept xdotool commands. (just adding so future readers are aware of this.)
    – Bob
    Oct 8, 2023 at 20:35
1

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

2
  • 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. Mar 29, 2018 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, 2018 at 9:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .