How to remotely log in with full graphical desktop over X11

XDMCP is designed for this. On your server, you need to enable XDMCP support in your desktop manager:

  • if you're using kdm, look for

    [Xdmcp]
    Enable=false
    

    at the end of your kdmrc, change false to true and restart kdm;

  • if you're using lightdm, add

    [XDMCPServer]
    enabled=true
    port=177
    

    to /etc/lightdm/lightdm.conf and restart lightdm.

Then on your client, start X using

X -query ${SERVER_IP}

(with the appropriate IP address instead), and your server's login screen should show up on your client.


You can start a window manager over an SSH session, but you need to ensure that your X server isn't running a window manager already then.

This can be accomplished in two ways:

  1. Do everything manually, rather than using startx or a display manager:

    First, start your X server:

    X -nolisten tcp :0
    

    now change to another virtual console (e.g., hit ctrl+alt+f2), and type:

    DISPLAY=:0 ssh -XC <host> startkde
    

    Now switch back to the first virtual console and use your X session normally. The downside of this method is that it doesn't include xauth setup (so that in theory everyone on the remote machine will be able to connect to your X session, which is a security risk); you may wish to add that.

  2. Use the .xinitrc (for startx) or .xsession (for display managers) files to modify your window manager:

    If you have set up your system so passwordless SSH works, (e.g., through ssh keys, or by using Kerberos or some other authentication mechanism), you can add the following line as the final line in your .xinitrc or .xsession files:

    exec ssh -XC <host> startkde
    

    The thing to remember is that whatever you add to those files will be executed instead of your normal X11 session setup. In some cases, you may need to select the "standard Xsession" option on your logon screen.

    Even if you don't have passwordless SSH, this may still work, provided you have ssh-askpass installed. If ssh determines that it doesn't have a controlling terminal but it does have a $DISPLAY variable set, it will use that to ask for a password.

    Downside of this method is that it becomes harder to log in to the "local" machine.


You can turn on the VNC server

Settings>Sharing>Screen Sharing

Then proxy forward 5900 over ssh to your pc if you need to use ssh.

ssh -L 5900:localhost:5900 #destination here

then use a Remote Desktop (RD) client like Remina to connect to the local ssh proxy so;

Connect>127.0.0.1:5900

Be sure to look into the security failures of VNC before you use it. VNC should be pretty safe to use if your tunneling it over ssh. This method will only work if you have an user logged in. In order to get it to work without a user logged in, you will need to ssh in, start a VNC server and specify what display to use I.E. 0, 1, 2 and then connect to it using Remina or something from wherever.