I have two machines, both running kubuntu: server & client. I’d like to connect to server from client and start the full graphical interface without fear that some commands would be run as client user.
So, ssh -XC works and I can also start graphical programs from it just fine.
However, when I type startkde in the ssh console, it says “KDE seems to be already running on this display.” Which is true, but not for the same user account.
I tried exiting graphical interface and logging in from tty, but that then (unsurprisingly) failed to start any graphical programs, including kde.
How then can I do this such that I could simply log in just as I log in with a local user? Use client machine as a dumb terminal.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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, changefalsetotrueand restartkdm; -
if you’re using
lightdm, add[XDMCPServer] enabled=true port=177
to
/etc/lightdm/lightdm.confand restartlightdm.
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.
Method 2
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:
-
Do everything manually, rather than using
startxor 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
xauthsetup (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. -
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
.xinitrcor.xsessionfiles: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-askpassinstalled. Ifsshdetermines that it doesn’t have a controlling terminal but it does have a$DISPLAYvariable 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.
Method 3
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0