xdotool from ssh to login

718 views
Skip to first unread message

mueller...@gmail.com

unread,
May 6, 2015, 3:13:27 PM5/6/15
to xdotoo...@googlegroups.com
(Sorry if this is duplicated... my browser hung when I submitted my question the first time)

Without going into the details of why I want to do this, I'm basically looking for a way to ssh into a remote Ubuntu box, and from the shell,
send the login password to the login screen of the computer. I have VNC starting when I get past the login screen, but not before... I'm
guessing this is not possible with xdotool, since it sounds like it only works from within X... and I guess if the computer is sitting at the
login screen, X hasn't even started yet... ignoring the fact I'm running xdotool from the ssh session, not an X session. Anyway, if anyone
has an idea to make this work, I'd appreciate your advice.

Thank you!

Anthony Thyssen

unread,
May 6, 2015, 8:49:09 PM5/6/15
to xdotoo...@googlegroups.com, mueller...@gmail.com
It should be possible! But tricky to set up. And there are alternatives.

First getting access to the login console display...

After you ssh to the machine, you need to get access to the console
login display. You need to set DISPLAY to ":0" (console), and also
get the X11 authentication. This would be in a root only file probably
located in /var/gdm or some where like that.

If you look at the environment of the running graphical login program
(typically gdm) you should see a XAUTH environment variable that points
to the root owned xauth file containing the 'access cookie', copy that
file to your home and readable by you, putting it into your ".xauth"
file or pointing XAUTH environment to it. so you can then drop root
permissions you temporarily needed to get it.

"sudo" can be used to automate root to grab the auth cookie, with
or without needing a password.

Once you have the display and authentication set, you should then be
able to use xdotool to control the console X display. You can then use
it to move/click the mouse pointer (or sent Alt-Tabs) to enable the
text input field for password (or username if not set), and send the
appropriate strings. Watch the actual console to see that your
requested actions are being followed as expected.


ASIDE: It may be possible that after getting DISPLAY and XAUTH permission
that you could export the console as a VNC server (using something like
x11vnc, x0vncserver, or x2vnc) directly. You can then use VNC to directly
view the login display. That will let you see and login on the console
without needing to use xdotool. If you don't mind not automating the
typing of the login password (and avoid putting passwords into a
program, which is never a good idea).

The key for this is weather gdm resets the X window server (and thus
set up a new cookie) during the login process. I doubt that it does.
But if it does you may need to use xdotool or VNC a second time.


Alternative...

ssh into the machine, but then just start a virtual X window display
which you can then VNC to. This will leave the console as is,
but give you a graphical screen running on the machine (like a console
but only displayed via VNC)

Commands that can start a VNC only X display (separate to console)
include...
vncserver
Xvnc
tigervnc-server-minimal -- is a wrapper around Xvnc

The only disadvantage of this is the console is not changing in front
of anyone watching as the X display you are using is completely virtual
(in memory only), and accessed only via VNC.


Anthony Thyssen ( System Programmer ) <A.Th...@griffith.edu.au>
--------------------------------------------------------------------------
Nitwit ideas are for emergencies. You use them when you've got
nothing else to try. If they work, they go in the Book. Otherwise
you follow the Book, which is largely a collection of nitwit ideas
that worked. -- Larry Niven, "The Mote in God's Eye"
--------------------------------------------------------------------------
Anthony's Castle http://www.ict.griffith.edu.au/anthony/

mueller...@gmail.com

unread,
May 7, 2015, 2:22:01 PM5/7/15
to xdotoo...@googlegroups.com, mueller...@gmail.com
Anthony,

Thank you -so- much for your help. I've got it working with your suggestions. The .Xauthority file is located in /var/lib/lightdm for Ubuntu/Unity.
Once I copied that into my home dir and changed its permissions, xdotool worked exactly as I wanted.

Thanks again!
-Stephen

P.S. I didn't start vncserver from the shell, because I want to use Unity... and everywhere I looked online, I could not find anyone who had Unity
working via VNC. I was able to get my old standard wm, fvwm2, working... but not Unity, which I prefer for the software update interface, etc.
Reply all
Reply to author
Forward
0 new messages