How to run two X sessions at the same time?

27,757

Solution 1

If you are running an X session under Ubuntu on machine A it will appear on screen:0 (Ctrl+Alt+F7) on A.

You want to run a remote X Session from machine B (on your Lan) without interrupting your current session on A.

Go to the first console screen (Ctrl+Alt+F1) login at the console and then ask Machine B to send an X session to screen: on A - like this

u@A:~$  X :1 -query IP-of-B

X asks for an X session, :1 says to put it on screen 1, -query asks for the session from in this case IP address of B

You will find the new session on screen :1 (Ctrl+Alt+F8).

This is not secure (no ssh) but is quick and easy for a home network when sound is not required over the connection.

You can use nomachine's nxclient/server which is fine but runs in your current session on A screen :0 in its own window. It provides support for local sound and local printing - last time I looked Firefox would not start up if sound was enabled.

Solution 2

ssh -X

The first and easiest option would certainly be "ssh -X", but this will only work when the system you connect from is already running an X server. So suppose you are running an Ubuntu machine and want to connect to another Ubuntu machine, you can type "ssh -X ipaddress" in the console. This will leave you with a console, but when you start any application that uses X from that console, it will be shown in your current X session.

XMing

If you would be running windows and want to start an X session on a remote Ubuntu machine, you can use XMing. XMing is basically an X server to run on windows. It is available on sourceforge.

To use XMing, XDMCP must be enabled on your Ubuntu machine. This was easily done in Ubuntu before 10.04. Nowadays, you have to update /etc/gdm/custom.conf as follows. Make sure to make a backup first! You don't want to mess up GDM with this ;)

[daemon]
User=gdm
Group=gdm


[security]
DisallowTCP=true

[xdmcp]
Enable=true
DisplaysPerHost=2
HonorIndirect=false
MaxPending=4
MaxSessions=16
MaxWait=30
MaxWaitIndirect=30
PingIntervalSeconds=60
Port=177

[greeter]

[chooser]
Multicast=false

[debug]
Enable=false 

Solution 3

Not quite an answer to your question, but...

You can run X-programs over ssh, I often use this to give me access to protected/restricted services on my LAN when i'm out. Basicly what it does is connect a pipe from you machine to an ssh-server ans forward the display from the server to the client, but the application is running on the server. By default the SSH client isn't setup for this but it can be enabled by using the -X option. Ex:

ssh -X user@host firefox

Actually this is how LTSP works these days. You might be able to find more information on how LTSP is doing when remotely using a whole session instead of just a single app.

Solution 4

I actually discovered another way to achieve this: with xrdp Install xrdp.

xrdp is a Remote Desktop server for Linux that creates a separate login session (with X) that can be accessed with Windows' Remote Desktop tool or with other RDP compatible applications.

Solution 5

FreeNX will also serve your purpose.

From Ubuntu Wiki:

FreeNX is a system that allows you to access your desktop from another machine over the Internet. You can use this to login graphically to your desktop from a remote location. One example of its use would be to have a FreeNX server set up on your home computer, and graphically logging in to the home computer from your work computer, using a FreeNX client.computer, using a FreeNX client.

https://help.ubuntu.com/community/FreeNX

Share:
27,757

Related videos on Youtube

Nathan Osman
Author by

Nathan Osman

Email: [email protected] I am both an Ubuntu user and Ubuntu member. By profession, I am a software developer and I work with C++, Python, and (more recently) Go. I enjoy tinkering with different things like motion tracking in Blender, creating an Android app for time-lapse photography, or writing Linux kernel modules. - 2buntu - community blog that I sometimes contribute to - NitroShare - a cross-platform network file transfer utility - REST Easy - Firefox add-on for analyzing HTTP responses

Updated on September 17, 2022

Comments

  • Nathan Osman
    Nathan Osman over 1 year

    I would like to run two X server instances at the same time.

    One would be an interactive session using the mouse and keyboard attached to the computer. The other would be a 'virtual' session that I could then connect to and use over a network.

    In other words, I want something like telnet/ssh that allows me to log in to my Ubuntu machine from somewhere else. However, I would like at least a basic graphics display when I log in.

    • richzilla
      richzilla over 13 years
      Im assuming you want to run two users on your computer simultaneously?
    • Nathan Osman
      Nathan Osman over 13 years
      @rich: Yes, but both should have a graphical display.
  • Nathan Osman
    Nathan Osman over 13 years
    +1 Thanks for explaining in detail how to do this - will other Linux distros running X be able to do the 'ssh -X' trick? For example, if I have a Fedora box, can I connect to my Ubuntu machine and run applications over X that way? (I'm grasping for the right terminology here, but failing :))
  • Nathan Osman
    Nathan Osman over 13 years
    Just tried this and it works great.
  • Admin
    Admin over 13 years
    @George: Remember X is a little backwards. The user runs the server locally which the individual applications (the clients) connect to.
  • McIntosh
    McIntosh over 13 years
    @George: As long as your Fedora box is running an X server, you will be able to use ssh -X. Basically ssh will make use of the X server on your Fedora box to show you the Ubuntu applications.
  • Nathan Osman
    Nathan Osman about 13 years
    This definitely helps.