5

I am new to SSH. I can connect to a remote computer. I can also launch an application on a remote computer and see its GUI on my screen.

But I do not know how to launch an application without it producing output on my screen.

I want to launch an application (eg. rhythmbox), and close the ssh connection, leaving the application running, without sending any output to my screen.

Surfing the web I have found some advice, but nothing helped me;

ssh -X name@domain
nohup rhythmbox &
logout
Zanna
  • 69,223
  • 56
  • 216
  • 327
0xDE4E15B
  • 187
  • 1
  • 7
  • 2
    Let me see if I've understood correctly. You want to connect from your laptop to your desktop, for instance, launch a music player which would then appear on the desktop and not on the laptop? In other words; you'd like to use another computer as a sort of remote control? – Jo-Erlend Schinstad Aug 22 '11 at 20:38
  • Yes, you're right! – 0xDE4E15B Aug 22 '11 at 21:54
  • You may need to play with the DISPLAY environment variable to force the GUI to display on an X Display that will not terminate when the connection is closed. In addition you would need nohup. What are you trying to accomplish firing up a GUI you cannot see? – Mark Bidewell Aug 22 '11 at 20:17

1 Answers1

3

Do you mean you want Rhythmbox to display onto the remote computer's screen? The screen onto which a GUI application is displayed is indicated by the DISPLAY environment variable. When you run ssh -X, DISPLAY is set to a value that indicates that display requests must be forwarded over the SSH connection. To make the application display on the remote computer's screen, set DISPLAY to the value :0.

ssh username@example.com 'DISPLAY=:0 rhythmbox &'

There's one more hurdle: when an application connects to an X display, it needs to provide a sort of password called a cookie. The cookie is generated each time the X server starts. Ubuntu stores the cookie in a file with a randomly generated name. The easiest way to find the cookie is to store it in a well-known file name when the X server starts. On Ubuntu, add this code to your ~/.profile:

case $DISPLAY:$XAUTHORITY in
  :*:?*)
    # DISPLAY is set and points to a local display, and XAUTHORITY is
    # set, so merge the contents of `$XAUTHORITY` into ~/.Xauthority.
    XAUTHORITY=~/.Xauthority xauth merge "$XAUTHORITY";;
esac

For more background, see ssh DISPLAY variable.


Or did you mean you never ever want to see the Rhythmbox window? If so, make it connect to a virtual X server, xvfb Install xvfb. Start the virtual X server, then tell Rhythmbox to connect to it.

ssh username@example.com 'Xvfb :1 -screen 0 800x600x8 & sleep 1; DISPLAY=:1 rhythmbox &'
Glorfindel
  • 965
  • 3
  • 13
  • 20
Gilles 'SO- stop being evil'
  • 59,745
  • 16
  • 131
  • 158
  • Anyway, in case of remote audio player on the local X server (`-X` option to ssh), where the sound will go? – enzotib Aug 22 '11 at 21:51
  • @enzotib The sound will be played locally, unless you've set up sound forwarding (unless recent versions of Ubuntu set up sound forwarding by default?). – Gilles 'SO- stop being evil' Aug 22 '11 at 21:58
  • You should probably use nohup or run the Rhythmbox in a screen session. Otherwise, when you close the terminal window on the client, Rhythmbox will be terminated on the server as well. – Jo-Erlend Schinstad Aug 25 '11 at 17:04