How can I run a program remotely via SSH but display locally

23

10

Is it possible for me to SSH to another server in Linux (Ubuntu), run a program there but display it locally?

And is it possible for me to SSH to another server in my terminal, and configure it so that all graphical programs (Firefox, Emacs) run in that SSH session will be displayed locally?

michael

Posted 2010-03-24T21:51:17.063

Reputation: 4 127

Answers

25

By adding the "-Y" flag to the ssh command, the display will automatically be redirected to your local computer.

ssh -Y <remoteip>

Then, if you start Firefox (or any other X application) in that ssh session, it will be displayed locally. (If you have a xserver running locally of course)

Laurent Parenteau

Posted 2010-03-24T21:51:17.063

Reputation: 648

2Very clever. I have used ssh for years & never knew that existed. – DaveParillo – 2010-03-29T06:47:30.990

Under Unixes like HP UX 11i, -Y is the way to go due to incompatibility issues with -X. – Owl – 2018-10-08T21:27:24.253

does this work when the remote machine is Windows? I can get it to display. – Mark Deven – 2019-01-19T21:19:27.157

1I will use -X since this way forwarding is subjected to X11 SECURITY. But if you trust the remote machine then you can use -Y. – fmanco – 2012-07-12T11:34:20.850

5

You are looking to do remote X. This is a good mini HOWTO.

mindless.panda

Posted 2010-03-24T21:51:17.063

Reputation: 6 642

err, not for anything headless that does not have X. htop for example. – mckenzm – 2019-03-23T23:03:34.083

3

You might also want to try this:

ssh <hostname> -X <program-name or its full path>

Xolve

Posted 2010-03-24T21:51:17.063

Reputation: 450

2

Use can also use compression when using X-forwarding:

ssh $HOSTNAME -CY $PROCESS

Vaibhav Bajpai

Posted 2010-03-24T21:51:17.063

Reputation: 523