6

I need to run firefox on a remote host via ssh and keep process running even after ssh logout.

I already have tried these ways:

nohup firefox &
screen
disown -h

But it seems these work only for the process without an X11 display, because these work fine with my scripts and I can keep my scripts running even after ssh log out. But I can't do the same for firefox.

How can I make this work for firefox too?

Lesmana
  • 26,889
  • 20
  • 81
  • 86
  • 4
    [Multiposted on Ask Ubuntu](http://askubuntu.com/questions/99336/firefox-process-dies-after-ssh-log-out-on-remote-machine). [Please don't do this.](http://unix.stackexchange.com/faq#cross-posting) – Gilles 'SO- stop being evil' Jan 28 '12 at 22:11

3 Answers3

3

Basically it looks like you need a flexible (just an app, not a whole desktop) X session through ssh that you can resume at any time.

I use NX for that. I've also used during some time x2go, but I always come back to NX.

Some links worth to look at:

And a couple of tutorials about NX:

hmontoliu
  • 1,937
  • 12
  • 11
1

The problem is that X-Windows clients require a X-Windows server to display. When that connection goes away, it is the same as clicking the 'X' button in the window's decoration. I believe there was some experimentation on getting a X client to switch between X servers, but I don't believe it was working properly. If that did work, you could start an X server on the remote system, and just before you exit the ssh session, tell the X client (firefox) to move to the remote X server instead of your X11 Forwarded server (local). Beyond that, I don't believe that you will get this to work since the X11 protocols require a server to talk to.

Arcege
  • 22,287
  • 5
  • 56
  • 64
1

As @Arcege says, it's not something that will work in X-Windows, no. You could run a basic VNC server to do the same job but VNC acts as a desktop rather than in "seamless" mode.

James O'Gorman
  • 273
  • 1
  • 6
  • how do i run basic server? Let me tell you that i have been given some space on cloud, to which I do ssh. I really don't have control on the kind of server running on the cloud.Further the cloud in behind a proxy and we can login to proxy only by creating a secure session via browser before getting connected to internet(outside campus).And i need to run twitter API for my project there even After I logout ! So please help me out – Pranay Agarwal Jan 28 '12 at 18:05
  • Something like: `vncserver -geometry 1024x768 -depth 24` will give you a _very_ basic server, probably with something like twm as the window manager. – James O'Gorman Jan 28 '12 at 18:10
  • Is there a way to somehow start firefox process as a child of init(or deamon) so that it doesn't die after the parent process(ssh session) is ended ? i also tried to run a script that starts firefox after 20 secs. but the script is able to start firefox only when I am connected to remote via ssh. if I logout then it can't start firefox 1 – Pranay Agarwal Jan 28 '12 at 18:14
  • No, as @Arcege mentioned X-Windows is a client-server protocol. Firefox would need an X-Server to connect to. It will die as soon as it loses connection to the server (or if it could never establish one in the first place). – James O'Gorman Jan 28 '12 at 18:17
  • 1
    An alternative, if you don't require graphics, would be to use `elinks` inside `screen`. – James O'Gorman Jan 28 '12 at 18:17