How to forward X through two SSH tunnels?

8,890

Solution 1

How about forwarding a port on your work computer to your home computer's port 22 and then ssh -Y to that local port?

For example,

ssh -L 2222:private-ip:22 router-ip
ssh -Y localhost:2222

Solution 2

What you've done should work, but you need to have the xauth program installed on the router so that it can create a security key for the virtual X11 display that SSH creates. You need xauth on any machine that you ssh -X or ssh -Y to, even if you don't actually run any X applications there, but just use it as a step toward somewhere else.

After you've connected to the home computer, check your $DISPLAY variable. It should be something like localhost:10. If not, go back to your shell on the router and check $DISPLAY there.

Share:
8,890

Related videos on Youtube

The_g U r U
Author by

The_g U r U

Hello there! My name's Jordan Earls, but most people online know me as "earlz". I'm the lead developer and a co-founder of the Qtum project which brings the Ethereum Virtual Machine (ie, the thing that makes Solidity contracts function) to a UTXO based blockchain similar to Bitcoin. I've been programming since I was 13 and am completely self-taught. Low-level code like assembly and pointer arithmetic is the fun stuff for me. I also make music when I have time even though it's usually awful. Most of my personal projects are open source and BSD licensed. The majority of them are at bitbucket with the rest of them being listed on github Also, you can follow me on the twitters @earlzdotnet

Updated on September 18, 2022

Comments

  • The_g U r U
    The_g U r U almost 2 years

    I'm trying to run an X program on my home computer from my work computer. The basic setup is this:

    Arch Linux work computer -> OpenBSD SSH router(at home) -> Arch Linux home computer(with SSH)

    I've never actually tried to do this and I'm not quite sure how to. How would I get this to work?

    When I just try doing

    $(work computer) ssh -Y home-ip
    ..
    $(home router) ssh -Y private-ip
    

    I get on the last tunnel "X11 forwarding request failed on channel 0"

    How do I do this properly?

    EDIT: I forgot to enable X forwarding on the sshd of my home computer. I've fixed that now, but nothing seems to happen when I do a simple command like xterm. It just sits there, presumably trying to display the xterm window on my router and not on my work computer

  • The_g U r U
    The_g U r U over 12 years
    Hmm.. Creative! That works for me :)
  • user1686
    user1686 over 12 years
    Not from, but to. The ssh client doesn't need to modify xauth data in any way. The server needs to create a temporary .Xauthority file.