Run SSH In The background After Running a GUI Linux Application

by on January 13, 2008 · 1 comment· LAST UPDATED June 11, 2014

in , ,

How can I run ssh (or gui over ssh) in the background after running a Linux or Unix GUI application? How do I run any UNIX x11 application in background with SSH Linux client?

You need to use ssh X forwarding feature. This is default feature of OpenSSH ssh client. All you have to do is run command as follows:

ssh {user@server-ip} -f -X {app-name}

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsOpenSSH ssh client/server
Estimated completion time2m

OR

ssh -f -X {user@server-ip} {/path/to/app-name} -arg1 -arg2

OR speed up with compression of all data:

ssh -f -X -C {user@server-ip} {/path/to/app-name}

Where,

  • user@server-ip : Your remote login username and password
  • -f : Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. This is the recommended way to start X11 programs at a remote site/host.
  • -X : Enables X11 forwarding.
  • -C : Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11 and TCP connections).
  • -c cipher : Selects the cipher specification for encrypting the session.
  • -T : Disable pseudo-tty allocation.

Example: Run ssh in the background

For example run xterm (x windows terminal) or xeyes app as follows and go into background, enter:
$ ssh vivek@d1.vpn.nixcraft.in -f -X xeyes
$ ssh vivek@d1.vpn.nixcraft.in -f -X xterms
$ ssh vivek@d1.vpn.nixcraft.in -f -X /opt/firefox/firefox

Tip: Speeding up slow links over ssh with compression

If you think that programs are running slowly because of a lack of bandwidth or network congestion, you can turn SSH compression by passing the -C option as follows:
$ ssh vivek@d1.vpn.nixcraft.in -f -X -C xeyes
$ ssh -fXC vivek@d1.vpn.nixcraft.in xterms
$ ssh -fXCT vivek@d1.vpn.nixcraft.in /opt/firefox/firefox
## Set ciphers. Blowfish is a fast block cipher; it appears very secure and is much faster than 3des ##
$ ssh -f -X -C -c blowfish-cbc,arcfour vivek@www544.nixcraft.net /path/to/raid-config-app

See also
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 Tom June 11, 2014 at 10:04 am

Thanks for this tip. I was struggling to find a way to fun a remote x11 application in the background. The ‘-f’ flag was the key

Reply

Leave a Comment

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: