Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.


I am new to SSH. So now I can connect to a remote computer. I also can launch an application on a remote computer and see it's GUI on my screen. But I do not know how to launch an application without outputting on my screen.
Basically I want to launch an application (eg. rhythmbox), and close the ssh connection, leaving the application running. Without having any output to my screen.

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

ssh -X name@domain
nohup rhythmbox &
logout

Hope you understood, sorry for my English.

share|improve this question
    
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
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

1 Answer 1

up vote 2 down vote accepted

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 [email protected] '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 [email protected] 'Xvfb :1 -screen 0 800x600x8 & sleep 1; DISPLAY=:1 rhythmbox &'
share|improve this answer
    
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 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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