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/