Linux – How to start remote Xorg/gnome via ssh & Xforwarding, then close ssh but without shutting down Xorg/gnome

linuxsshwinex11forwarding

Question:

I have a Linux server where I connect to via ssh.
It works fine, and also, X-forwarding works fine (in the local network).

Now I wanted to run a server program under wine. because it's a Windows application, it doesn't run on the command line, so I have to start it via x-forwarding. So far not a problem, works wonderfully.

My problem is I connect to the target computer with X-forwarding, like this:
ssh ip.of.target.computer -X

then I start

gnome-session 

from the ssh terminal. Gnome loads and i can start the graphical server application via wine. But when I want to logout from the X-forwarding, that closes the gnome-session (and the server X-window-application)…

How can I login, start a X-window application, and then logout ssh without closing the X-application ?

Best Answer

You might find the -N option useful:

 -N      Do not execute a remote command.  This is useful for just for‐
         warding ports (protocol version 2 only).

and/or the -T option:

 -T      Disable pseudo-tty allocation.

That way you won't get a shell prompt.

Try combining it with disown.

ssh <host> -X -N -T &
disown %<number>

where <number> is whatever number is printed in bracket after running the ssh command.

For example:

$ ssh -X -N -T myserver&
[1] 10317
$ disown %1

That will detach ssh from the shell and window, so you can close the window and ssh will keep running.