You want to use XDMCP. Run a copy of (G|K|X)DM on B, with no screens
defined (so it doesn't try to create a display locally) and set it to
allow XDMCP. Then run an `X :1 -query B` on A, and it'll connect to B's
GDM and let you log in.
Make sure you're well firewalled off from the internet before doing any
of this -- XDMCP isn't secure and it doesn't use ssh.
If you don't want to use XDMCP, you could just fire up an X server on A
with `X :1` then do a `DISPLAY=:1 ssh -X B (startkde|fvwm|sawfish)` or
similar, and all should work.
OK,