Reverse X11 forwarding

7,427

Solution 1

If I understood it correctly you just need to use the DISPLAY variable on your phone to redirect the applications display to your desktop.

On your desktop:

xhost +phone_ip

On your phone:

export DISPLAY=desktop_ip:0

start app

Solution 2

"reverse ssh tunnelling" or "remote port forwarding" is your friend.

issue this on the phone

ssh -f -N -X -R 5555:localhost:22 desktop_user@desktop

then, on the desktop this

ssh -X -p 5555 phone_user@localhost

Share:
7,427

Related videos on Youtube

Oli
Author by

Oli

Hi, I'm Oli and I'm a "full-stack" web-dev-op. Eurgh. I'm also allergic to jargon BS. I spend most of my professional time writing Django websites and webapps for SMEs. I write a lot of Python outside of Django sites too. I administer various Linux servers for various tasks. I contribute to the open source projects that I use when I can. I'm a full-time Linux user and that has lead to helping other people live the dream. I am an official Ubuntu Member and I earnt my ♦ on SE's own Ask Ubuntu in 2011's moderator election. That's probably where I spend most of my unpaid time. I also run thepcspy.com which has been my place to write for the last decade or so. If you need to contact me for extended help, you can do so via my website, just remember that I have bills so if I feel your request is above and beyond normal duty, I might ask for remuneration for one-on-one support. For more social contact, you can usually find me (or just my computer) lurking in the Ask Ubuntu General Chat Room and on Freenode in #ubuntu and #ubuntu-uk under the handle Oli or Oli``.

Updated on September 17, 2022

Comments

  • Oli
    Oli over 1 year

    I was playing with my phone (that runs a Linux/X stack) last night and I managed to ssh into my desktop and run an application and have it show up on my phone. It was awesome.

    Today I'd like to sort of do the opposite. I want to view an application running on my phone on my PC. I could install a SSH server on my phone but I frankly don't fancy that purely for security reasons. I want this to be initiated from my phone.

    Is there a way to connect from my phone and tunnel the PC's X connection back to the phone and then run an application on the phone that show on the PC?

  • Oli
    Oli over 13 years
    But I need this tunnelled over SSH. And to the PC the connection would look like it was coming from a localhost (where the ssh server is) so I'm not sure it needs xhost. My understanding of this gets a bit blurry because I don't know what TCP port X runs on. I don't know what I'm supposed to forward and I don't know how to construct the DISPLAY=... statement on the phone to use the forwarded port.
  • João Pinto
    João Pinto over 13 years
    Actually I should notice that with GDM X is started with "-nolisten", you can check that with: ps -ef | grep nolisten. You will need to change that to start with. I am not sure how to change it. Once X is listening I believe the TCP port is 6000 + display nr
  • Oli
    Oli over 13 years
    Urgh. At that rate it might just be easier to run a SSH server on my phone that only binds to localhost. From there I could SSH to my desktop and run another SSH connection back (tunnelled over the first) with X forwarding and in that run the program. Sounds nasty.
  • inetknght
    inetknght about 5 years
    Requiring the user to SSH in both directions violates the constraint of not running an SSH server on the phone.