I have a SSH server running in my home computer, with X11Forwarding enabled. I would like to connect to my computer from another computer and run some graphical programs. The problem is, that if a particular program is already running in my home computer, then it won't run again in my remote computer. All it does is gain focus in the home computer.

I believe this problem can be solved if I could find a way to open 2 instances of the same program. I know that if I connect to another user, or run the program from another user in my local computer than I would be able to run the same program twice, once in each user.

So I believe a solution would be to simulate a run of the program as another user. Problem is, I have only 1 user account, and I do want to run the programs - remotely, and locally from that particular user (which has access to my files and settings).

What is the simplest way to accomplish it?

(I'm running Ubuntu)

  • 1
    which applications are you talking about? most likely it wil be simpler to instruct your applications to start a new instance, rather than trying to connect to an already running one. e.g. firefox -new-instance – umläute Nov 2 '13 at 18:30
  • In a comment below I mentioned PyCharm for one... it doesn't support -new-instance, or any other arguments except a filename. – rboy Nov 2 '13 at 18:34
  • 3
    This is a deficit in these programs themselves, when they discover they are already running they don't bother checking if they are being asked to open on a new display. If you use VNC instead of X11 forwarding you can connect to your home computer and interact with the programs there. VNC is also more performant for many applications. Running Pycharm locally and getting at your files through sshfs would probably work even better. – wingedsubmariner Nov 2 '13 at 18:46
  • 1
    I'm inclined to agree with windedsubmariner that this is a deficit in the programs not being able to have subsequent windows displayed to alternate desktops, and for essentially not respecting the $DISPLAY. – slm Nov 2 '13 at 19:05
  • I'll definitely consider VNC, but I still prefer my solution better since I ssh into my computer anyway, and ssh already provides me with an option to control programs... further more, correct me if I'm wrong, but VNC uses more bandwidth than X11Forwarding.. and this might be a problem when I find myself in situtations where I have a limited bandwidth (such as connecting from my mobile modem as an hotspot, which has limited bandwidth by my cellular company, but I'm really diverting from the subject :)) – rboy Nov 2 '13 at 19:41

Many GUI applications can take an additional argument of -display. You should be able to set the -display switch to the $DISPLAY for the ssh tunnel which should display these secondarily opened windows through the tunnel.

If the -display switch isn't present then you have 2 alternative methods as I see it.

  1. Something along the lines of -new-instance which breaks a new GUI window from the pre-existing one.
  2. Getting the application to respect any $DISPLAY correctly instead of attaching new GUIs to the pre-existing process which is already being displayed on the primary desktop.
  3. Use VNC over SSH.


If you're going to use VNC I'd recommend using Vinagre. It's included as part of the GNOME desktop so there isn't any crazy setup. Under the pulldown:

"System" → "Preferences" → Remote Desktop

You'll find the configuration area for enabling the VNC server component within your existing GNOME desktop.

Once you've enabled it I typically use either the vncviewer command line tool to invoke or the Remote Desktop Viewer Tool. For me it's under the pulldown menu:

"Applications" → "Internet" → Remote Desktop Viewer

This again is the standard offering that comes with GNOME. I believe the entire package is all called Vinagre too.


  • I'm looking for a more generic solution.. I checked your solution on some program I use a lot to develop Python (PyCharm), and it doesn't support this argument. – rboy Nov 2 '13 at 18:22
  • You can set the DISPLAY environment variable instead of using -display, all X11 programs should support this. – wingedsubmariner Nov 2 '13 at 18:47
  • @wingedsubmariner - I figured that too, but if he was ssh'ing into the box then -X and -Y would need to be set, and if say firefox was already running I think the OP is right that the new firefox's would display themselves on the display already being used, rather than send the window over the tunnel. I thought -display might provide a path for getting out of the $DISPLAY since it's likely already set, yet still going to the main desktop. – slm Nov 2 '13 at 19:03
  • @wingedsubmariner when I ssh into my computer remotely with the -X option, the $DISPLAY variable is already set correctly (and is different from the local $DISPLAY).. but once a program is running, it is bound to the $DISPLAY it was first launched on. – rboy Nov 2 '13 at 19:42
  • @RB14 - that's exactly what I figured and is why I didn't even bother to suggest futzing with that setting, since it's apparently having no effect on the 2nd launches of GUI windows. – slm Nov 2 '13 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.